Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

All I do below is with Visual Studio 2010. I cannot use Sharepoint Designer because I don't have the right to do it.

I have a Content Type, which is the associated content type of a page layout. They are deployed with Feature without problem. The page layout has some publishing page instances.

I now add a column to the Content type, and deployed the project. Now on my site collection the field is added in Column list and the Content Type is updated. I want to add the new field to the page layout. I edited the page layout by adding the corresponding SharePointWebControls. But when I try to add new page or edit the existing pages using the layout, the newly added column won't show.

I've done lots of search, and quite a lot of people have encountered the same problem. I followed the article here: http://www.sharepointnutsandbolts.com/2010/06/feature-upgrade-part-1-fundamentals.html. A great article indeed, but not regretfully covering page layout updating subject. I tried adding the following code the sample in the article:

<Feature xmlns="http://schemas.microsoft.com/sharepoint/"  Version="1.0.0.0">
    <UpgradeActions>
        <VersionRange BeginVersion="0.0.0.0" EndVersion="0.9.9.9">
            <AddContentTypeField ContentTypeId="0x010100C568DB52D9D0A14D9B2FDCC96666"
            FieldId="{a816136e-ad2c-47d0-cb5a-023d2afb5be1}" PushDown="TRUE"/>
        </VersionRange>
    </UpgradeActions>
</Feature>

But it doesn't work.

And here in this article: http://madalina.blog.com/2012/01/updating-sharepoint-page-layouts-the-right-way/ it describes in this situation we should reset the page layout to its site definition. But I would prefer doing it all programatically with Visual Studio.

I wonder if I could change something in the Feature EventReceiver, like override the FeatureUpgrading Method? Or it simply goes with some configuration in the .xml file? Or I still have to do additional coding...

Or maybe, should I do it again from the start with the Object Model? I just discovered the method, I don't know a lot about it yet. (And here is a comparison between feature based XML and Object Model: Feature based XML vs. Object Model: Which is better for content type development?)

Please help me, thanks!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The method you are proposing in your code is simply meant to update the Content Type (and Children - which should actually consider the instance of the CT on the page library intended). To update the actual Page layout to display your new field, I would strongly suggest to simply create a new Page layout and in the Upgrade method push it down, as the Default page layout.

The main issue with updating existing is the fact that as long as it in use it does not allow updating programatically (only via SPD), and in addition you need to keep count on the Publishing process -it needs to be published to see updates to the physical file. To function, your process should be:

  1. Push updates to the Content Type - at the Site Collection level - unless you do that, will never work. At this stage you should see that Content Type display your changes everywhere, but not visible on any page of course.
  2. [this is the tricky step - most complicated] Each Page using the exact Page Layout must be updated to use another Temporary Page Layout (compatibile with your Content Type to avoid loosing data). That is why i suggested, create a new one with field included to avoid reverting back. Once this is done FOR ALL pages, you could update the existing Page Layout.
  3. Revert back all pages updated to the new updated page layout.
share|improve this answer
add comment

Your Answer

 
discard

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.