Understanding XML in Sitecore Renderings Field

Anton Tishchenko
Anton Tishchenko
Cover Image for Understanding XML in Sitecore Renderings Field

Understanding XML in Sitecore Renderings Field

Sitecore has many interfaces to work with presentation. You can change it via Experience Editor, or via Layout>Details dialog from Content Editor. And you are able to do all that you want. But sometimes, it is not enogh. Sometimes, when you have too many renderings on your page that it is much easier to look inside XML, in which presentation details are serialized, and do everything there. Caution: It is not recommended and you should not touch this XML directly unless you are not 100% sure what are you doing.

Let's dive deep and understand, what is present in that XML. For example, I will take a piece of the presentation of the Habitat home item.

<r xmlns:p="p"
    xmlns:s="s" p:p="1">
    <d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}">
        <r uid="{96440B7A-F411-4281-B690-302C5468E355}" p:before="*" s:ds="{658E89F6-3F0C-4072-88CA-50CE81757A9D}" s:id="{5A21C781-8E74-4DD0-8261-8CCDA1BF0454}" s:par="GridParameters=%7B113BEF7C-97E6-46CA-8CF3-916F7FAA8DE2%7D&amp;Styles=%7B5F1937B9-3A84-4F4B-A96E-C60419A06667%7D&amp;Navigation=%7BF5A400A0-C183-4A46-892A-F4DE38A5ECDE%7D&amp;Transition=%7BD4B706CC-7EEC-4DB9-A87D-123B29803490%7D&amp;Timeout=2000&amp;PauseOnHover=1&amp;Reset Caching Options&amp;RenderingIdentifier&amp;DynamicPlaceholderId=13" s:ph="/main/sxa-content-container/container-1">
            <rls>
                <ruleset>
                    <rule uid="{B3EE3027-9A67-4696-800B-2F7B4D619DD4}" s:name="Foodie">
                        <conditions>
                            <or uid="58709978E4BB4AF7A9814D1CD8EF7EC6">
                                <or uid="4F0B55B8EAA94AE284B2DE656A69F16B">
                                    <condition uid="73058D8C9428448DACD02E3D6D630283" s:id="{A0CDF81A-7727-4418-B331-E1AEC80EFAB0}" s:ExpectedAncestorTaxonId="{67BA62FE-7F1A-4BA1-B244-79160A0893C4}" s:CustomFieldId="{336BA862-E974-4CD6-BE4D-4BFDD78994E1}" />
                                    <condition uid="A64E09ABEEB7406AA29207D109D92D5E" s:id="{E00DB4F0-B206-4544-AD90-25D201CFB62C}" s:ProfileName="Topic Interest Category" s:PatternName="Cooking" />
                                </or>
                                <condition uid="21A4C1FE5B7145069C0B322AD2936B82" s:id="{08A70C4F-93B5-409E-9967-3892AAEB3BC2}" s:PatternList="{B7A02EED-A729-42B0-978B-2C6EF479FC8F}" />
                            </or>
                        </conditions>
                        <actions>
                            <action uid="EB19DB65DA0A4273B21828B383D0B574" s:id="{0F3C6BEC-E56B-4875-93D7-2846A75881D2}" s:DataSource="{C531430C-246D-4AC0-86D2-61B834F07269}" />
                        </actions>
                    </rule>
                </ruleset>
            </rls>
        </r>
        <r uid="{C3B8C2EE-F9DC-44C4-8837-93681B962081}" p:after="r[@uid='{96440B7A-F411-4281-B690-302C5468E355}']" s:ds="{874ED455-AF6F-438D-BEA8-1916B7FAB5BD}" s:id="{00E2C7CF-2247-4596-B878-E6BB3850A77F}" s:par="DynamicPlaceholderId=12&amp;GridParameters=%7B113BEF7C-97E6-46CA-8CF3-916F7FAA8DE2%7D" s:ph="/main/sxa-content-container/container-1/container-11" />
        <r uid="{1C0F3249-32A1-475D-8E69-8B2111ED267D}" p:after="r[@uid='{C3B8C2EE-F9DC-44C4-8837-93681B962081}']" s:ds="local:/Data/CTA - The Perfect Home Theater" s:id="{51C13F03-8364-4F61-B860-2EC6CA7439B3}" s:par="DynamicPlaceholderId=3&amp;Caching=0%7C0%7C0%7C0%7C0%7C0%7C0%7C0&amp;FieldNames=%7BB8DCE263-F093-4EF3-9B53-B4A4B919A337%7D" s:ph="/main/sxa-content-container/container-1/container-10"/>
        <r uid="{C03747C0-B0DC-467F-AA8D-126A4FFFABE9}" p:after="r[@uid='{6B1C256F-3488-4908-BB96-B7746E471A36}']" s:ds="" s:id="{896A2C68-1362-4E88-8BA0-1805AE6D4837}" s:par="Styles=%7B37959667-EE0C-4E0F-8A37-5687BB143510%7D&amp;GridParameters=%7B113BEF7C-97E6-46CA-8CF3-916F7FAA8DE2%7D&amp;DynamicPlaceholderId=9" s:ph="/main/sxa-content-container/container-1" />
        <r uid="{81BDD83F-35B1-49D1-9B7C-8C0BE1189F83}" s:ds="" s:id="{896A2C68-1362-4E88-8BA0-1805AE6D4837}" s:par="Styles=%7BB32CF8A3-6E9B-4D8B-992C-91B8C667FFFA%7D%7C%7B9CB76B6C-2B77-4728-8508-CF7041C7B69C%7D&amp;GridParameters=%7B113BEF7C-97E6-46CA-8CF3-916F7FAA8DE2%7D&amp;DynamicPlaceholderId=11" s:ph="/main/sxa-content-container/container-1" />
    </d>
</r>

Let's go one by one in the tree:

  • Parent r element — root element of presentation definition
  • d element — d stays for device. It could have next attributes:
    • id — identifier of device. This valued corresponds to ID of Device item.
    • l — identifier of the layout. This value corresponds to the ID of the Layout item. For our case attribute is absent, as it was configured on __Standard Values item.
  • r element — rendering definition. It could have next attributes:
    • uid — a unique identifier. It is a uniquely generated ID, which doesn't correspond to anything in the content tree. UID values are used for the generation of placeholder keys when Dynamic Placeholders are used. When you have an identifier in the placeholder key, you can find in which element this placeholder is present by looking for uid.
    • p:before — attribute that is used for ordering of rendering on page.
    • p:after — similar to p:before. It is used to set order of elements on a page.
    • s:ds — datasource of the element. It corresponds to the ID of the item that was selected as datasource for this rendering
    • s:par — rendering parameters. It is a serialized dictionary of key-value pairs divided by ampersand between pairs and with an equal sign between key and value. It also contains the caching configuration of rendering. (It looks like in old Sitecore versions, caching was serialized by other attributes, like cac, vbd, vbdev, vbl, vbp, vbqs, vbu, ciu. But they are not used anymore)
    • s:ph — placeholder, where rendering should be inserted.
    • s:pt — personalization test ID if it is present of the rendering
  • rls and ruleset — containers for configuration rules on rendering. ruleset has one attribute
    • s:pet — equals true, when you personalize not only data source, but also change rendering. It equals false or absent when the only datasource is changed
  • rule — container for rule definition. It contains:
    • uid — unique identifier of rule
    • s:name — name of rule
  • conditions — is a container for all conditions of a rule
  • or and and elements — are used for building logical conditions when there are many rules. They also have a unique identifier attribute:
    • uid — unique identifier
  • condition — condition serialization. It can have many different values because each condition can have different values. Here are listed only attributes that are common for each condition:
    • uid — unique identifier
    • s:id — ID of the Sitecore item which corresponds to definition of the condition
  • actions — container for all actions that should be done with rendering if rules execution returned true
  • action — definition of an action that should be done on a rendering. It has next attributes:
    • uid — unique identifier
    • s:id — ID of the Sitecore item which corresponds to definition of action. Usually, it is ID of "Hide Rendering", "Set Data Source", "Set Rendering" or "Set Parameters" item
    • s:DataSource — if action is "Set Data Source" then this attribute corresponds to new datasource ID of the Sitecore item
    • s:RenderingItem — if action is "Set Rendering" then this attribute corresponds to new rendering ID of the Sitecore item

Conclusion

It is not a full list. There also are others XML elements and attributes that could be present in your rendering definition. But they are quite rare and there is very small chance that you will face with them. This list give you additional knowledge to perform some tasks quicker. But, please use this knowledge with caution. It is very easy to break something when you edit rendering XML directly and don't use Sitecore interfaces(Content Editor or Experience editor) for it.