SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When deploying a custom page layout that uses a custom content type, I need to include the hexadecimal value of the PublishingAssociatedContentType property. This is a problem since this value will be different for each of our environments. Having a separate elements.xml file for each environment does not fit in with our deployment strategy.

Can I omit the value from the elements.xml and programmatically set it from within a feature receiver? What would that look like?

share|improve this question
up vote 0 down vote accepted

Yes I do believe you can. At least I've made mistakes before where it wasn't set properly but it was still provisioned fine, and I could fix it through the Layout's properties in the UI (directly on Production I might add.. But that's another story) :-)

You should be able to assign a string containing the same value as in your XML file :


Note that the PublishingAssociatedContentType is Sealed, so you will need to get the field, set its Sealed flag to false, set its value, set it back to Sealed, then .Update()

Why do you have a different associated content type on each environment?

share|improve this answer
In each environment the content type has the same name and is based on the article page content type. I've found though that the hex value is different in each environment. Should it be the same? If that's the case, it would certainly simplify things. – SF1Dev Mar 1 '12 at 16:17
The out of the box article page content type ID should be the same everywhere at the site level. Inside the list it gets copied into a child (variable) content type, but you can bind your layout to the (fixed) site-level ID. – Louis Mar 1 '12 at 16:56
Yes, but of course I need to bind my layout to a custom content type that is only based on the Article Page content type. My custom content type already exists in each environment and has a different content type id in each environment. Do I need to remove this content type id from each environment and create it through code, so that I can control the generated ID myself? This seems like more work than it should be just to deploy a page layout that uses a custom content type. – SF1Dev Mar 1 '12 at 19:10
A related answer is here:… but your sealed advice helped as well. Thanks! – SF1Dev Mar 2 '12 at 23:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.