Ever wanted to allow your editors to select multiple items in a Rules Engine Condition? You are in luck Sitecore has a TreeList Macro you can use.
Too add it to a rule use the syntax below.
where My Sitecore Item is [ItemId,TreeList,root=/sitecore/content,specific item]
Which looks like this when you select it.
This will give the editor a TreeList control starting at the /sitecore/content level, but what if you want to filter the displayed items or the items that can be selected from the TreeList?
There are parameters you can use to restrict which items will display and which items you can select similar to the TreeList field you would use in the CMS as detailed here but the parameters names and behavior are different.
Here’s an example of a TreeList Macro configured to restrict selection and display –
where My Sitecore Item is [ItemId,TreeList,root=/sitecore/content&selection=Sample/Sample Item&display=Common/Folder|/Sample/Sample Item,specific item]
You’ll notice the selection and **display **parameters these allow you to restrict items using the defined templates to display in the TreeList and which items can be selected. How you define that is by using the full path of the Template Excluding **/Templates **from the path, you can add multiple templates using the pipe separator.
Here is the Rendered TreeList Macro with the filtering applied.
I could not find any documentation relating to how this control works but by digging around in the Sitecore.Kernel.dll I found where these parameters are evaluated against a templates collection using the FullName property.