This blog post explains a technique that you can specify classes that contain logic to determine the source items to include in fields that present lists when working in the Sitecore ASP.NET Web Content Management System (CMS) and Customer Engagement Platform (CEP).
Certain types of fields such as multilists allow the user to select one or more items from a flat list. To determine the items to include in such lists, Sitecore invokes the getLookupSourceItems pipeline. Processors in this pipeline determine whether to return a list by checking the Source property of the field definition item, which may indicate a Sitecore query or item.
In Sitecore 7, the /App_Config/Include/Sitecore.Buckets.config Web.config include file adds the CustomDataSources processor to this pipeline. If the Source property of the data template field does not begin with the code: prefix, the CustomDataSources pipeline does nothing. Sitecore invokes the ProcessQuerySource processor. If the Source property does not specify a Sitecore query, the ProcessDefaultSource processor determines an item from the Source property and returns its children. If the Source property does not specify an item, then the ProcessDefaultSource processor returns the children of the item selected in the Content Editor.
If the Source property of the data template field begins with the code: prefix, then the CustomDataSources processor creates an instance of the class specified by that Source property, which implements the Sitecore.Buckets.FieldTypes.IDataSource interface. The CustomDataSources processor invokes the ListQuery() method defined by the IDataSource interface to determine the items to include in the list.
To implement a class that you can use with this technique to determine the items to include in a list:
SC = Sitecore;
CustomFieldDataSource : SC.Buckets.FieldTypes.IDataSource
SC.Data.Items.Item ListQuery(SC.Data.Items.Item item)
(item.Parent.ID == SC.ItemIDs.ContentRoot)
Alternatively, you could add a processor to the getLookupSourceItems pipeline.
Hi, Is there any way to pass additional parameters to ListQuery? Thanks, Meng
@Meng: Sorry for the lack of response - I just saw your comment. Did you find a solution? My assumption would be to pass them in the Source property of the field.