Query Support on Rendering Datasources

I recently had a requirement for setting up datasources on standard fields of a templates in a multi-site.

So i needed the datasource of a rendering to point to a different folder for each site.

e.g.

SiteA/Global/Navigation

SiteB/Global/Navigation

 

This job can be easily done on Template sources using Source but its a bit tricky when It Comes to Rendering Datasources.

As it turns out the Rendering Datasource has to be of certain format in order for Sitecore to call the rendering. If the Query Syntax is not appropriate, Sitecore would just skip the rendering altogther.

In order to achieve this, I had to make a custom pipeline that replaces Sitecore's EnterRenderingContext pipeline.

and registered the Pipeline

Now I was able to query Sitecore just like a normal query.

query:./ancestor-or-self:://*[@@id='{43440D8E-E6AC-4F36-A5A5-53DB5CEFE369}']//*[@@templateid='{F44A8BAC-17C7-4A34-A84A-9B5F8CBBCEDC}'

Leave a Reply

Your email address will not be published. Required fields are marked *