Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitecore presentation details don't update on template change

I'm working on a Sitecore (6.4.0.101124) site that has two templates used for the home page. These have a very similar structure - the big difference between them is that they each have one different sublayout in the Controls section of the Presentation Details of the Standard Values. My understanding is that when the template is changed on an item the standard values of the template should be applied to that item. However, when the content editors change the template the presentation details remain the same until I go in and change them.

So this means that either I misunderstand how this is supposed to work, or something wonky is happening. This is a very similar problem to what's discussed in this thread, but the answers given don't seem to apply since this item was not created using a branch template.

Has anyone had a similar experience with this (and solved it)? Am I way off base in how this is supposed to work?

like image 862
user1712896 Avatar asked Oct 01 '12 20:10

user1712896


2 Answers

You write:

My understanding is that when the template is changed on an item the standard values of the template should be applied to that item.

This is only true if a field has not been edited. Once a field for an item has been edited, the edited value takes precedence over the default. Changing the template to one that has different Standard Values will only have an impact if the field has not been touched, or if the user resets the field to the default value using the Fields Reset button. (Note that manually clearing the field will not do the trick. Sitecore will store an empty string, which will override the Standard Value. By using the Reset button, you set the field to a Database Null, which causes the Standard Value to be used.)

Reset Button

You can tell if a field has been edited by checking for the text "standard value" next to the field in the Content Editor:

Standard Values display hint


Sitecore 6.4.0 and Layout Deltas

Things are more complex with the Renderings field on Sitecore 6.4.0 and above, because Sitecore introduced a feature called "Layout Deltas" with this release. Before Layout Deltas, if you edited the presentation details of an item, Sitecore would copy the layout information from the "Renderings" field of Standard Values into the item's Renderings field, which had the consequence that any subsequent change to Standard Values Renderings would have no effect on the display of this item.

This functionality made it difficult to manage changes to presentation, since a minor change to a detail of presentation on an individual item, such as adding conditional rendering logic, would break the inheritance from Standard Values. If if was necessary to change the presentation of a class of items, it was necessary to first change Standard Values, and then to make the same change to every item that modified presentation.

With Sitecore 6.4's Layout Deltas, if you modify the presentation of an item, just the change is stored in the item's Renderings field, rather than a complete copy of the Standard Values rendering. This change, or delta, information is applied on top of the Standard Values Renderings information, so that modifications to Standard Values layouts are applied to all inheriting items, not just ones with unmodified presentation.

It sounds like your content editors have made a modification to the presentation of the item. When the template is switched, this change is being applied on top of the new template. You can confirm this by checking for the [Standard Values] text next to the Renderings field of the item in question.

like image 87
Dan Solovay Avatar answered Nov 29 '22 20:11

Dan Solovay


The template has values, but what carries the values to the items that are created using that template is in the standard values item. Now, that being said, each field on an item that is created from that template has a flag that says whether or not its using template standard values. If the presentation details are NOT flagged as using standard values still, then its not going to cascade down the updates to the items.

Now.. to be sure that you understand the difference between a branch and a template.. a branch is sort of a "model" of how you can create an item. It is NOT going to cascade changes down when you make changes to the branch item at all. Items will inherit values from their TEMPLATE standard values. The branch values inherit only upon item creation.

EDIT: By the way, I should add that if you turn on the gutter on the left to show presentation overridden, you can see if the presentation values are standard values or not. If you see the icon, then you know the item is not currently using standard values.

like image 30
divamatrix Avatar answered Nov 29 '22 19:11

divamatrix