BikerP
BikerP

Reputation: 868

Sitecore - Restrict item by Data Template Type on a Field

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.

Upvotes: 3

Views: 8493

Answers (2)

Zachary Kniebel
Zachary Kniebel

Reputation: 4774

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:

  1. IncludeTemplatesForSelection - Users can only select items based on this comma-separated list of data template names
  2. ExcludeTemplatesForSelection - Users cannot select items based on this comma-separated list of data template names
  3. IncludeTemplatesForDisplay - Users can view items based on this comma-separated list of data template names and IDs
  4. ExcludeTemplatesForDisplay - Users cannot view items based on this comma-separated list of data template names and IDs
  5. IncludeItemsForDisplay - Users can view items based on this comma-separated list of item names and IDs
  6. ExcludeItemsForDisplay - 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:

  1. Filter - Note that there is a bug in Sitecore 7.0 when using this parameter to filter templates that I discussed in another blog post
  2. TemplateFilter - Discussed in the post for the bug discussed above, as a workaround

Upvotes: 5

Marek Musielak
Marek Musielak

Reputation: 27132

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.

Upvotes: 12

Related Questions