I'm on Sitecore 8.2, using MVC. I have two sites, and I'm defining presentation details on Standard Values of the template, so that I can use one presentation details setup for rendering the same component on both sites, just with different content.

When putting the component (rendering) on the page, we have this field for choosing the datasource item: enter image description here Here I can either use "Browse" link to find the exact Sitecore item to use, or I can enter a query expression like on the screenshot. I've added a custom processor into mvc.renderRendering pipeline that interprets that query expression and replaces the query with the exact path to the item.

If I'm on site A it will give me path sitecore/content/siteA/controls/navigation and if I'm on site B it will give me path sitecore/content/siteB/controls/navigation.

It all works very good for me.

The problem is when I need to personalize the component. Based on some condition, I would like to change the datasource of the component to be:


But, the problem is that the "Content" field in the personalization window is not allowing me to enter the query. It only allows me to choose the individual item: enter image description here The only workaround I have found so far is to choose the individual item here, and then go to raw values of presentation details (__Renderings field) and replace the guid there for my query expression.

That works, but it's clumsy, and there's no way content authors will know how to do that if they had to.

Is there a way in the personalizations window to get the same kind of Data Source field as in the component properties window (the one that allows free text entry along with browsing for individual Sitecore item)? Or any other solution for this problem?

  • Hi. I had the same task couple weeks ago. So I decided to use addFromTemplate pipeline/processor to set up necessary datasource during adding the item. I've used this approach github.com/kamsar/BranchPresets In your case it can be done in the same way. But you need to update the logic to get datasource from correct folder under correct site. In my opinion using sitecore query in rendering datasource field can be quite difficult to understand for nontechnical content editors. if it acceptable to you let me know I can move it to answer. – Vlad Apr 3 '17 at 17:01
  • Hi, @Vlad! I've looked at the link you provided. I understand what it does, but I don't think it's applicable in solving my problem. I'm basically trying to overcome a problem in Sitecore UI where at one place I can enter datasource as plain text, and at the other place I can't. Those two places should offer the same functionality. I agree that Sitecore query might be too difficult for some content authors, so we're also providing them with some macros, like $brand, that they can use instead of that ancestor-or-self::*[@@templatename='Website'] construct, to make their life easier. – Dalibor Kovač Apr 4 '17 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.