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?

4
  • I send you a chat invite
    – Chris Auer
    Commented Mar 18, 2019 at 20:47
  • Sorry, not seeing anything? Commented Mar 18, 2019 at 20:51
  • 2
    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
    Commented Mar 18, 2019 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? Commented Mar 19, 2019 at 12:17

1 Answer 1

0

I don't think there is an 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 and acknowledge you have read our privacy policy.

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