1

I have a requirement to show the datasource item in droptree field and its a multi site solution. My content tree structure is as below

WebSite A
        Home
          
        
        Global
            Blog
                Blog Promo Card

    WebSite B
        Home
        
        Global
            Blog
                Blog Promo Card

My requiremet is to show items dynamically based on sites based on this template (Blog Promo Card). So in drop tree field on item level i should show items creted from block promo card template.

2 Answers 2

4

You need to use a dynamic source query like this, that will match the same content tree structure for each site.

query:./ancestor-or-self::*[@@templateid='SITE TEMPLATE ID']//*[@@templateid='GLOBAL ITEM TEMPLATE ID']//*[@@templateid='BLOG TEMPLATE ID']

Also if you want to fix the path of your Content tree structure after a certain point then the query will be something like this. (In case you are using Folder to hold item)

query:./ancestor-or-self::*[@@templateid='SITE TEMPLATE ID']/Global/Blog/Blog Promo Card

Follow this article for more information

https://sitecoresandbox.com/tag/droptree/

Hope this helps.

2
  • Thanks that resolved my issue. May 9, 2022 at 10:09
  • @AvinashSharma - accept the answer if it worked so that help quickly others. May 10, 2022 at 6:39
3

You have to write your dynamic source query for drop tree field like this, it will works for multisite solution and shows item based on your current site.

query:./ancestor::*[@@templateid='{23DA3211-A3A4-4E46-8ABD-FDE132236DCB}' or @@templateid='{23DA3211-A3A4-4E46-8ABD-FDE132236DCB}']]//*[@@name='Globals']//*[@@name='Blog']//*[@@name='Blog Promo Card']/* 
1
  • Thank for answering this. but with this query item takes lots of time to get loaded. May 9, 2022 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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