I'm working on a Sitecore 8.1 installation. I'm trying to use a droptree field to allow content editors to pick one item (data template A) from a tree of items. Each item that's a valid selection is guaranteed to have one or more child items of a different data template (data template B). According to the documentation, this should be easy to do: just set the source to either a parameterized datasource:
Datasource=/sitecore/Media Library/Images/Folder&IncludeTemplatesForDisplay=Data Template A
or a query:
query:/sitecore/Media Library/Images/Folder/*[@@templatename='Data Template A']
For some reason, though, the field seems to ignore anything but the path. It will display the correct portion of the tree, but shows all items (including those of Data Template B) and allows them to be selected. I've tried various permutations of [Exclude|Include]TemplatesFor[Selection|Display]
, none of which has proven effective. I've also tried excluding B from the query using [@@templatename!='Data Template B']
or both approaches with templateid
.
I haven't been able to find a lot of information about this, other than the occasional vague reference to droptree not honoring exclusions. The common solution seems to be using a TreeList with a regex validation to limit it to one selection. This approach is adequate, but not really what I'd prefer: the TreeList UI is a bit weird for single selection, and I'd prefer to just not allow a user to select multiple items at all rather than throwing a validation error when they do.
There are a few other fields I could use that honor the exclusions but don't present a tree view: again, serviceable but not idea, as there could potentially be a lot of items here and the tree view provides the user with some helpful context.
I could probably write a new field type that mimics the Droptree but actually honors the exclusion--and I'm stubborn enough that this may be the route I take--but I wanted to check first to make sure I wasn't just missing something. So that's the question: anyone know of a way to make a Droptree honor either ExcludeTemplatesForSelection/Display or filtering by query before I go ahead and write my own?
Sitecore DropTree
field does not support IncludeTemplatesForSelection
or IncludeTemplatesForDisplay
parameters.
They work only with Treelist
, TreelistEx
and Mulitlist
fields.
What you can use is FilteredTree
field type created by Richard Cabral.
You can find it from git here: Filtered Tree by Richard Cabral at github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With