Sitecore Field: Multi-Root Treelist

On nearly every Sitecore site I’ve built, we’ve had a need to display 2 separate sections of the content tree in a single treelist field. The most common use-case being, having a folder to hold components local to the current item, and a shared folder for all items to use. Until now, I had never taken the time to take that code and make it generally applicable to any Sitecore site, opting to port the code from one site to another. So without further ado, the Multi-Root Treelist:

A View from the Content Editor:
Multi-Root Treelist Content Editor View

Configuration:
Multi-Root Treelist Template Builder View
On the desired field, from the Template Builder, select the field type named ‘Multi Root Treelist’. In the source field, define your datasources by path or by ID. For instance, for two datasources the syntax would be: Datasource=[path or ID of first root item]&Datasource2=[path or ID of second root item]. The source field also allows for relative paths. So, if you want one datasource to be relative to the current item, start the datasource with a ‘.’. For example, Datasource=./components identifies the components folder which is a child item of the current item.
 
So, by now you’re hopefully wondering, ‘That’s all well and good but how do I get my hands on this?’. As of the time of this post you can download the source from GitHub: https://github.com/OptimizedQuery/Sitecore.MultiRootTreelist. Installation is easy, just install the package found in the /sitecore directory and add the following lines to /App_Config/FieldTypes.config in your site’s web root.

1
2
<!-- Custom Field Types -->
<fieldType name="Multi Root Treelist" type="Sitecore.Data.Fields.MultilistField,Sitecore.Kernel" />

That’s all there is to it. Take it for a spin and let me know what you think.
 
**NOTE** Solution on GitHub references Sitecore v6.6 DLLs and .NET Framework v4.0.

3 thoughts on “Sitecore Field: Multi-Root Treelist

    • Sorry for the delayed response. Thanks for reaching out. I’m working on trying to get this field working in v7.5. I hope to have something in GitHub soon.

      • That would be very useful with sitecore 7.5. Also i noticed that the values on the field type item in the core database are Endocrine.Library and Endocrine.Library.CustomSitecore.Fields.MultiTreeList.MultiTreeList, shouldn’t that be Sitecore.MultiRootTreelist and Sitecore.MultiRootTreelist.Code.MultiRootTreeList ?
        Best,
        Pierre

Leave a Reply