Controlling the list of items in a Selection field

Abstract

How to control the items that appear in the selection list for fields that allow the user to select items.

The Source property of data template fields supports three techniques for controlling the items that appear in the selection list for fields that allow the user to select zero or more items.

Note

If you set the Source property of a data template field to a Sitecore query or Treelist parameter as described in the following sections, you might receive a prompt indicating that the Source field in the data template field definition item contains one or more broken links. You can ignore this warning and save the change to the data template field definition item.

You can set the Source property of a Droplink, Droplist, Droptree, File, Grouped Droplink, Grouped Droplist, Image, Multilist, Treelist, or TreelistEx field type to a root item. For single-level lists, such as Checklist, Droplink, Droplist, or Multilist, users can select a child of the root item. For grouped lists, such as Grouped Droplink and Grouped Droplist, users can select a grandchild of the root item. For tree lists, such as Droptree, File, Image, Treelist, and TreelistEx, users can select a descendant of the root item.

For example, to allow selection from beneath the /Sitecore/Content/Home item, set the Source property as follows:

/Sitecore/Content/Home

You can set the Source property of a Checklist, Droplink, Droplist, Grouped Droplist, Grouped Droplink, or Multilist field to a Sitecore query using the query: prefix.

For example, to allow selection of children of the home item that are based on the data template named Section:

query:/sitecore/content/home/*[@@templatename='Section']

You can set the Source property of a Treelist or TreelistEx field type to any number of key=value parameters separated by ampersand characters (&).

For example, to allow users to select descendants of the home item that are based on either the data template named Section or the data template named Page:

DataSource=/Sitecore/Content/Home&IncludeTemplatesForSelection=section,page

You can specify the following parameters:

  • DataSource: Root item.

  • DatabaseName: The name of the database containing DataSource.

  • IncludeTemplatesForSelection: Users can only select items based on this comma-separated list of data template names.

  • ExcludeTemplatesForSelection: Users cannot select items based on this comma-separated list of data template names.

  • IncludeTemplatesForDisplay: Users can only navigate items based on this comma-separated list of data template names and IDs.

  • ExcludeTemplatesForDisplay: Users cannot navigate items based on this comma-separated list of data template names and IDs.

  • IncludeItemsForDisplay: Users can only navigate items based on this comma-separated list of item names and IDs.

  • ExcludeItemsForDisplay: Users cannot navigate items based on this comma-separated list of item names and IDs.

  • AllowMultipleSelection: If yes, users can select the same item more than once.