Understanding Rendering and Final Rendering XML Raw Values

Author

Brandon Bruno

Published

March 30, 2021

Tags

Understanding Rendering and Final Rendering XML Raw Values

Sitecore's presentation layer can sometimes be straightforward and other times convoluted - most of the time it sits somwwhere in the middle. Understanding how presentation works involves deep understanding of concepts such as Layouts, Sublayouts, Renderings, MVC Layout, the relationship between Shared Layout and Final Layout, and many other concepts (don't get me started on headless).

When debugging issues with an item's presentation, it is important to understand how Sitecore stores presentation data. All items based on the Standard Template include the following two fields:

  • Renderings (field: __Renderings) - stores shared presentation
  • Final Renderings (field: __Final renderings) - stores version-specific presentation, used to create a delta with the Renderings field

Each of these two fields stores the actual layout information in the form of XML. Enabling Raw Values in the Content Editor will display this XML. For example, this is the Renderings presentation XML for the default home item that comes with Sitecore:

<r xmlns:xsd="http://www.w3.org/2001/XMLSchema"><d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}" l="{14030E9F-CE92-49C6-AD87-7D49B50E42EA}"><r ds="" id="{885B8314-7D8C-4CBB-8000-01421EA8F406}" par="" ph="main" uid="{43222D12-08C9-453B-AE96-D406EBB95126}" /><r ds="" id="{CE4ADCFB-7990-4980-83FB-A00C1E3673DB}" par="" ph="/main/centercolumn" uid="{CF044AD9-0332-407A-ABDE-587214A2C808}" /><r ds="" id="{493B3A83-0FA7-4484-8FC9-4680991CF743}" par="" ph="/main/centercolumn/content" uid="{B343725A-3A93-446E-A9C8-3A2CBD3DB489}" /></d><d id="{46D2F427-4CE5-4E1F-BA10-EF3636F43534}" l="{14030E9F-CE92-49C6-AD87-7D49B50E42EA}"><r ds="" id="{493B3A83-0FA7-4484-8FC9-4680991CF743}" par="" ph="content" uid="{A08C9132-DBD1-474F-A2CA-6CA26A4AA650}" /></d></r>

It's not very pretty, so let's format it:

<r xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}" l="{14030E9F-CE92-49C6-AD87-7D49B50E42EA}">
		<r ds="" id="{885B8314-7D8C-4CBB-8000-01421EA8F406}" par="" ph="main" uid="{43222D12-08C9-453B-AE96-D406EBB95126}" />
		<r ds="" id="{CE4ADCFB-7990-4980-83FB-A00C1E3673DB}" par="" ph="/main/centercolumn" uid="{CF044AD9-0332-407A-ABDE-587214A2C808}" />
		<r ds="" id="{493B3A83-0FA7-4484-8FC9-4680991CF743}" par="" ph="/main/centercolumn/content" uid="{B343725A-3A93-446E-A9C8-3A2CBD3DB489}" />
	</d>
	<d id="{46D2F427-4CE5-4E1F-BA10-EF3636F43534}" l="{14030E9F-CE92-49C6-AD87-7D49B50E42EA}">
		<r ds="" id="{493B3A83-0FA7-4484-8FC9-4680991CF743}" par="" ph="content" uid="{A08C9132-DBD1-474F-A2CA-6CA26A4AA650}" />
	</d>
</r>

It looks like a lot is going on, but it's fairly easy to parse this once you understand its structure. The XML nodes represent the same list of devices and renderings that you see in the Presentation Details dialog for an item. Attributes on each node stores data specific to the instance of each rendering.

Here's a breakdown of nodes in the example above:

  • <r></r> - a rendering (or sublayout, etc.); the top-level node is also <r>, but doesn't represent a specific rendering
  • <d></d> - device definition; this groups device-specific renderings together

The various attributes in each node represent:

  • id - Item ID of the rendering, device, or datasource item
  • uid - a unique ID assigned to this instance of the given item; this is only found in this XML markup and is not visible in the Presentatil Details interface
  • ds - ID of the datasource item, if assigned (the above example has no datasources)
  • par - rendering parameters; stored as HTML-encoded key-value pairs
  • ph - placeholder identifier
  • l - ID of the associated layout for this device; seen only on the device node (<d>)

You will encounter other attributes, such as cac (caching enabled), vbd ("vary by device"), and p:after/p:before (used to define ordering of renderings). There are more attributes used throughout the presentation layer, and most can be configured through the Presentation Details dialog, so don't be afraid to tinker and find out what they all do.

Be careful if you modify this XML - even the slightest malformed XML will wreck your item presentation. On the other hand, understanding, parsing, and manipulating this XML is very handy for certain debugging situations.

In one recent example, Sitecore was reporting broken links on an item. I tried removing all known links to other items and reset presentation; no such luck. It turned out that default presentation on the standard values of an item had an incorrect ID in the par (rendering parameters) field. I removed the incorrect ID from the XML and my issue was solved.

Do you have questions, comments, or corrections for this post? Find me on Twitter: @BrandonMBruno