Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You explained in your comments that you want to display certain sublayouts in the sidebar depending on certain form parts/steps. You can do that by adding a PlaceHolder that will fit the sublayouts (e.g. in your sidebar) and use this code to dynamically render sublayouts to it.</p> <p>First you need an item (i call it a snippet item) that has the sublayout configured on its presentation settings. Then you can use code to render that item inside the placeholder (phSideBarPlaceHolder).</p> <pre><code>// Load snippet item Item snippet = Sitecore.Context.Database.GetItem("{id-or-path-of-snippet-item}"); // Get the first rendering from item's presentation definition RenderingReference rendering = snippet.Visualization.GetRenderings(Sitecore.Context.Device, false).FirstOrDefault(); // We assume that its a Sublayout, but you can also check for xslt and create an XslFile() object Sublayout sublayout = new Sublayout(); sublayout.DataSource = snippet.Paths.FullPath; // creates a reference to the snippet item, so you can pull data from that later on sublayout.Path = rendering.RenderingItem.InnerItem["Path"]; sublayout.Cacheable = rendering.RenderingItem.Caching.Cacheable; // Copy cache settings if (rendering.RenderingItem.Caching.Cacheable) { sublayout.VaryByData = rendering.RenderingItem.Caching.VaryByData; sublayout.VaryByDevice = rendering.RenderingItem.Caching.VaryByDevice; sublayout.VaryByLogin = rendering.RenderingItem.Caching.VaryByLogin; sublayout.VaryByParm = rendering.RenderingItem.Caching.VaryByParm; sublayout.VaryByQueryString = rendering.RenderingItem.Caching.VaryByQueryString; sublayout.VaryByUser = rendering.RenderingItem.Caching.VaryByUser; } // Now render the sublayout to the placeholder phSideBarPlaceHolder.Controls.Add(sublayout); </code></pre> <p>If you need more info about how to read data the DataSource property inside the sublayout code, Mark Ursino has written an article about that: <a href="http://firebreaksice.com/using-the-datasource-field-with-sitecore-sublayouts" rel="noreferrer">http://firebreaksice.com/using-the-datasource-field-with-sitecore-sublayouts</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload