Global Office Directory
More Products
Share this page
Home > Community > Technical Blogs > Getting to Know Sitecore > Layout Deltas What Ifs
In this post I explore another of Sitecore 6.4's new features: layout deltas. In some ways, this feature is similar to cloning. Both features allow changes in one place to be inherited to other places, so they both simplify reuse. Both allow some values to be inherited and other values to be overridden. And both features take advantage of Sitecore's existing architecture to work their magic.
I am going to use a very simple site to walk through some basic scenarios, explaining how layout deltas work in each case.
I have a site with the following:
The standard values for Template 1 are set so Device 1 uses Default Layout, and Rendering 1 and Rendering 2 are added to a placeholder named "content".
Sitecore stores this (and all presentation details) in the item's Renderings field. The value in this case is:
<?xml version="1.0" encoding="utf-16"?> <r xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <d id="{Device 1}" l="{Default Layout}"> <r id="{Rendering 1}" ph="content" uid="{control 1}" /> <r id="{Rendering 2}" ph="content" uid="{control 2}" /> </d> </r>
The d-tag represents the device. The l-tag represents the layout. The r-tags represent the renderings. Well, except for the top-level r-tag :-)
Next, I create an item named Item 1 using Template 1. When I look at the Renderings field value for this item, I see the standard values for Template 1. The values match, but Sitecore's interface also reflects this.
If I change the layout for Item 1 to Layout 2, the value for the Renderings field has changed. Notice that only enough information is written to describe the change I made:
<r xmlns:p="p" xmlns:s="s" p:p="1"> <d id="{Device 1}" s:l="{Layout 2}" /> </r>
Next I add another Rendering 3 to Template 1's standard values.
The Renderings field value for Template 1's standard values is:
<?xml version="1.0" encoding="utf-16"?> <r xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <d id="{Device 1}" l="{Default Layout}"> <r id="{Rendering 1}" ph="content" uid="{control 1}" /> <r id="{Rendering 2}" ph="content" uid="{control 2}" /> <r id="{Rendering 3}" ph="content" uid="{control 3}" /> </d> </r>
If I look at the Renderings field value for Item 1, it has not changed:
But if I look at the presentation details for Item 1, I see that Rendering 3 is included as a control. This is what layout deltas are: an item inherits presentation details from its template's standard values.
If I replace Rendering 2 with Rendering 3, and Rendering 3 with Rendering 4 in Item 1...
...Item 1's Renderings field value is indicates that a control 2 has been changed to Rendering 3 and control 3 has been changed to Rendering 4.
<r xmlns:p="p" xmlns:s="s" p:p="1"> <d id="{Device 1}" s:l="{Layout 2}"> <r uid="{control 2}" s:id="{Rendering 3}" /> <r uid="{control 3}" s:id="{Rendering 4}" /> </d> </r>
If I remove control 2 from Template 1...
...the Renderings field value from Template 1's standard values is:
<?xml version="1.0" encoding="utf-16"?> <r xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <d id="{Device 1}" l="{Default Layout}"> <r id="{Rendering 1}" ph="content" uid="{control 1}" /> <r id="{Rendering 3}" ph="content" uid="{control 3}" /> </d> </r>
And the value of Item 1's Renderings field hasn't changed...
...but the presentation details have:
Why have Rendering 3 and 4 switched places? Remember, the Renderings field is only reporting the changes. The presentation details screen shows the effect those changes have on the settings inherited from the item's template. Sitecore uses the template's Renderings value as a guide. It follows those instructions, and then handles any instructions that are in the item's Renderings value:
I want to mention one more thing: what happens if you have upgraded from a previous version of Sitecore? In this case, the values for the Renderings fields will not be in layout delta format. So what happens? I have my suspicions, but since I don't have a Sitecore server I can upgrade, I will have to leave this final question unanswered.
Tags: Architecture
- Matthijs Wensveen June 23, 2011 at 4:07 PM
Adam is a technical architect on Sitecore's Product Marketing Team. He is responsible for spreading technical knowledge inside and outside of the company, with an emphasis on external systems and applications.
This website is designed to be fully functional with scripts disabled in browser. Please contact the webmaster for any suggestions