What is the proper syntax for a 'Grouped Droplink' field? I can't seem to find proper documentation on this anywhere.
Can I use this to group results from 2 sections of the content tree?
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.Sign up to join this community
Short answer - Sort of, but only in a specific way.
Similar to fields such as Lookup, Multilist and TreeList, this field uses the fields's
source property to retrieve a collection of items using the
getLookupSourceItems pipeline. This pipeline allows for the
source property to be interpreted in different ways for how to retrieve these items (e.g. a single item ID, a piped list of IDs, or a query). This pipeline is extensible so you can add other ways of interpreting the property to retrieve a list of items.
However, the field then renders each of these items from the pipeline as the group headers, and then shows the children of each of these as the selectable items under each header.
So if what you had in mind involved the selectable items as always being the children of a collection of items, then yes you could likely use this field.
If you need more flexibility, you could instead look at creating a new field type that implements similar functionality to
Sitecore.Shell.Applications.ContentEditor.GroupedDroplink for how it renders the list, but it could interpret the
source property differently to build the grouped collection of items.
The 'Groupped Droplink' field treats every item "returned" by its source as a separate group. Then all child items of every "group" item are selected and rendered as options for each group. That is why the above approach does not work with the 'Groupped Droplink' field
The following documents on SDN provide description of the field specifics:
Content API Cookbook (chapter 4.1.8: How to access Droplink, Droptree and Grouped Droplink Fields): http://sdn.sitecore.net/Reference/Sitecore%206/Content%20API%20Cookbook.aspx
Data Definition Reference ('The Grouped Droplink Field Type' section in the chapter 4.2.3): http://sdn.sitecore.net/Reference/Sitecore%206/Data%20Definition%20Reference.aspx
Data Definition Cookbook ('Root Item' section in the chapter 2.4.2): http://sdn.sitecore.net/Reference/Sitecore%206/Data%20Definition%20Cookbook.aspx