4

So, I have multiple organizations content on my site, they are all grouped into a regional content area, and I also have a global content area. One of my templates looks into a folder that has a photo item which they can use on their pages, but it's presented to them as a droplink field. I have it working fine for their individual organization via the following query:

query:ancestor::*/Photos//*[@@templateid='{55A41A27-A674-4A04-9716-8E5CB8786A85}']

I want to also add to this droplink options for the global and regional photos. I tried just concatenating, eg:

  query:ancestor::*/Photos//*[@@templateid='{55A41A27-A674-4A04-9716-8E5CB8786A85}']|/sitecore/content/All Organizations/Photos//*[@@templateid='{55A41A27-A674-4A04-9716-8E5CB8786A85}']

However, this just concatenates two separate queries, which is fine for the individual organization level, but for the global area, it essentially is finding the same items twice, and duplicating them in the droplink. I'm wondering if there's any way to do essentially a distinct for a this kind of query, or is that just not available?

  • I send you a chat invite – Chris Auer Mar 18 at 20:47
  • Sorry, not seeing anything? – Levi Wallach Mar 18 at 20:51
  • 1
    I could not get the ancestor:: to work in my processor, since I am in the core database when it is running. So here is functional code, but it will only run on relative queries. Which is not what you asked for, gist.github.com/dnstommy/8372c785b1916900caee2a3d75ca0e34 – Chris Auer Mar 18 at 21:02
  • Thanks, I have it working as well without the ancestor, can you think of any way I can emulate that in code? – Levi Wallach Mar 19 at 12:17
0

I don't think there is option to select unique results in Sitecore query.

But you can do something like this to filter out the results by checking if the "Photos" item id on the "ancestor query" is part of your Global content area

query:ancestor::*/Photos[@@id!='{ID of /sitecore/content/All Organizations/Photos}']//*[@@templateid='{55A41A27-A674-4A04-9716-8E5CB8786A85}']|/sitecore/content/All Organizations/Photos//*[@@templateid='{55A41A27-A674-4A04-9716-8E5CB8786A85}']

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.