How to set Sitecore Droptree source to the item itself
Asked Answered
G

2

5

I want to set the source of a droptree to the item so every time I create an instance of that template I can select it's children. Obviously I can't add the ID of the item to the template as it will be different for every instance of the template.

I tried $id in the vain hope that that might work but it didn't.

Is there a way to do this?

Gehman answered 28/3, 2012 at 8:54 Comment(0)
B
7

I think you can just use a query and simply set the source to a relative path:

query:./*

This should set the source to the children of the current node.

Bonus: you can use most query expressions as source, making it possible to filter items based on templates or more complex operations. Check out the query doc at SDN to get started.

Braden answered 28/3, 2012 at 11:9 Comment(3)
Sadly this doesn't work when added to the Source field in the template builder. I read the document and tried a few things from there (e.g. @@ID) but none of it sets the source correctly.Gehman
What version of Sitecore are you using? This worked for Sitecore 6.2.0 (100507).Platus
Yeah, I just re-tried it all again and it's working. Very strange to be honest - it really wasn't working before! Thanks, just what I was looking for. =)Gehman
R
2

You can always use simple XPath queries such as self:: or parent:: . For sets of items it could be descendant:: or child:: . But in your case I believe it will be self::

Reichenberg answered 6/1, 2015 at 12:4 Comment(1)
To expand on this, the source would be: query:self::Hoad

© 2022 - 2024 — McMap. All rights reserved.