I would like to restrict the data type of items a user can select on a field. I can do this by Insert Options of tree node in the field's source, but this feels a little open to abuse - say a developer accidentally moves an item of the wrong type under this node then the system falls down. I am possibly over worrying this, but in other CMS I have had the ability to restrict the type of an item a user can select. What is the best way to go about this.
3
votes
2 Answers
10
votes
For the field types like Treelist
or Multilist
you can set the source
parameter of field with additional parameters like IncludeTemplatesForSelection
, e.g.
DataSource=/sitecore/content/home/employees&IncludeTemplatesForSelection=Employee
Here is a post explaining how to use source
and here is another one called Tame your Sitecore treelist.
4
votes
I actually wrote a blog post the other day that includes information for filtering the Treelist, Multilist, Treelist with Search, and Multilist with Search (everything you need for Sitecore 6-7).
I think you would be most interested in the following parameters for the Treelist and Multilist:
IncludeTemplatesForSelection
- Users can only select items based on this comma-separated list of data template namesExcludeTemplatesForSelection
- Users cannot select items based on this comma-separated list of data template namesIncludeTemplatesForDisplay
- Users can view items based on this comma-separated list of data template names and IDsExcludeTemplatesForDisplay
- Users cannot view items based on this comma-separated list of data template names and IDsIncludeItemsForDisplay
- Users can view items based on this comma-separated list of item names and IDsExcludeItemsForDisplay
- Users cannot view items based on this comma-separated list of item names and IDs
For the Treelist with Search and Multilist with Search, take a look at the following:
Filter
- Note that there is a bug in Sitecore 7.0 when using this parameter to filter templates that I discussed in another blog postTemplateFilter
- Discussed in the post for the bug discussed above, as a workaround