Anders G. Nordby

Lead Consultant at Itera

Monthly Archives: September 2012

Ensuring disablePageTypeUpdation=”true” in a CMS 6 environment with PageTypeBuilder and shared database

With PageTypeBuilder and CMS 6, when several devopers share the same database, it’s a good idea to have the strangely named disablePageTypeUpdation set to true, so that you don’t inadvertedly create problems for the other developers on your team (as found on Joel Abrahamson’s blog):

<configuration>
  <configSections>
    <section name="pageTypeBuilder"
type="PageTypeBuilder.Configuration.PageTypeBuilderConfiguration,
PageTypeBuilder"/>
  </configSections>
    <pageTypeBuilder disablePageTypeUpdation="true" />
</configuration>

However, after setting this to false for making necessary updates to the database, it’s much too easy to forget reverting this before checking in to source control. Therefore, I’ve written the following PowerShell script:

# PowerShell script to ensure that file is always checked in with disablePageTypeUpdation="true"
$webConfig = "C:\...FULL-PATH-HERE...\web.config"
$doc = new-object System.Xml.XmlDocument
$doc.Load($webConfig)
$doc.SelectSingleNode("//pageTypeBuilder").disablePageTypeUpdation = "true"
$doc.Save($webConfig)

Then, I added this as a post-build event:

powershell -noprofile -command "&{ start-process powershell -ArgumentList '-noprofile -file .\ensureDisablePageTypeUpdation.ps1' -verb RunAs}"

Now, as long as everyone remembers to build before they commit, the disablePageTypeUpdation setting will always be set to true when committing. Maybe I should write a custom check-in policy to ensure this, but not today…

Advertisements