Friday 19 November 2010

Sitecore Treelist filtering

We have a treelist for selecting content to display as lists. The editor only needs to select the parent and not any of the children. Using the default source for a treelist to point to the containing folder you allow the editors to see all the children.

You could write a query like below to exclude or include the templates you require:
/sitecore/content/DisplayItems/descendant-or-self::*[@@templatename!='Template1' and @@templatename!='Template2' and @@templatename!='Template3']

This can be changed to use the following format which is easier to read and has more options.
Datasource=/sitecore/content/DisplayItems&ExcludeTemplatesForDisplay=Template1,Template2,Template3

Using this approach, there are several other parameters that you can set like:
  • IncludeTemplatesForSelection
  • ExcludeTemplatesForSelection
  • IncludeTemplatesForDisplay
  • ExcludeTemplatesForDisplay
There is more reading and options on this at LearnSitecore

No comments: