Estate Digital – Tech Sitecore blog

Page Editor

Offcourse we all know that there is a way to set queryable datasources to sublayout definitions in the Sitecore database to help us select appropriate data for our renderings. This can be done using a module that you can find on the marketplace:

This module – when you specify a sitecore query – changes the rendering datasource to a new location. This can be very handy when you work with the page editor and want content of specific items to be placed underneath the content item itself. You can then for example place a “/content” folder underneath your items to hold the specific content that will be displayed on your item.

What I’ve noticed during development of a new Sitecore website that uses the page editor is that it can be very handy to have a complete page setup for our content editors so they see how a page should look. Giving the editors the ability to change existing layout is generally more appreciated than giving them a blank page that they have to fill from scratch everytime they add a new page / content item.

To achieve this goal we create a new “branch” for this set of items that will help our editors to quickly fill a new content item. This branch could for example have the following structure:

What you see here is a branch on which we have filled specific content items and other data template based items that will be used in our branch. When the content editor creates a new item from this branch, we wanted the presentation details of this branch to have those items preselected without having them central /in a shared folder somewhere in Sitecore. Every branch would then create this structure and the item created would have it’s own items underneath that would be used in the presentation. This offcourse could be done with the same concept as we’ve seen before in the Queryable Datasource. We went to see how Sitecore actually determines what item to present in a sublayout and found out we could play a little with the “ProcessContextQuerySource” pipeline.

We did the following: (after decompiling the Sitecore.Kernel.dll)

Create a new processor definition in the config that replaces the ‘Sitecore.Pipelines.InsertRenderings.Processors.AddRenderings, Sitecore.Kernel’ pipeline.

Now when sitecore is adding renderings to the page and finds a rendering that has a query: in the datasource it will be picked up as a special rendering. This class will extract all renderings with “query:” in it’s datasource and sets the appropriate datasource for those renderings. Pretty neat huh?

You can now add a sublayout on your branch item with the following query to set default text:

When the item is created from the branch it will initially point to the item underneath itself, but the content editor is free to change to another datasource if needed. When you click the ‘set associated content’ button the usual stuff will happen, making sure that you can set different content as datasource.

I do realise that this concept is taken from the queryable datasource, tho I think that this might be useful to setup a branch with item specific data underneath the content item itself (without having to create shared content items somewhere to point at from the datasource).