I have the content structure as follows:


The user should be able to select articles & rewards in the treelist field. For the source query, I entered:

includetemplatesfordisplay=Articles Folder,Category Folder,Article,Rewards Folder,  
Month Folder,Reward&includetemplatesforselection=Article,Reward

It only shows the content node when trying to select.
When I keep only the includeitemsfordisplay parameter it shows as:


I followed @Swati Gupta's example but it shows a plain text field

enter image description here

  • 1
    From what I see, first IncludeItemsForDisplay filter is applied and then includetemplatesfordisplay and with that you got 0 results in the tree. Or do I miss something here? – Marek Musielak Sep 12 '19 at 9:25
  • @MarekMusielak I think that might be the reason. I even tried using includeitemsfordisplay later, but no luck. Could you please advice any good alternate – Qwerty Sep 13 '19 at 15:04

If you want to give the option to select from multiple datasource, then you can create a custom control.

  1. Create new item MultiDatasourceTreelist using /sitecore/templates/System/Templates/Template field type template in core DB in this location /sitecore/system/Field types/User Defined/MultiDatasourceTreelist

enter image description here

  1. Create a class MultiRootTreeList
 public class MultiRootTreeList : TreeList
        protected override void OnLoad(EventArgs args)
            Assert.ArgumentNotNull(args, "args");

            if (!Sitecore.Context.ClientPage.IsEvent)
                // find the existing TreeviewEx that the base OnLoad added, get a ref to its parent, and remove it from controls
                var existingTreeView = (TreeviewEx)WebUtil.FindControlOfType(this, typeof(TreeviewEx));
                var treeviewParent = existingTreeView.Parent;

                existingTreeView.Parent.Controls.Clear(); // remove stock treeviewex, we replace with multiroot

                // find the existing DataContext that the base OnLoad added, get a ref to its parent, and remove it from controls
                var dataContext = (DataContext)WebUtil.FindControlOfType(this, typeof(DataContext));
                var dataContextParent = dataContext.Parent;

                dataContextParent.Controls.Remove(dataContext); // remove stock datacontext, we parse our own

                // create our MultiRootTreeview to replace the TreeviewEx
                var impostor = new Sitecore.Web.UI.WebControls.MultiRootTreeview();
                impostor.ID = existingTreeView.ID;
                impostor.DblClick = existingTreeView.DblClick;
                impostor.Enabled = existingTreeView.Enabled;
                impostor.DisplayFieldName = existingTreeView.DisplayFieldName;

                // parse the data source and create appropriate data contexts out of it
                var dataContexts = ParseDataContexts(dataContext);

                impostor.DataContext = string.Join("|", dataContexts.Select(x => x.ID));
                foreach (var context in dataContexts) dataContextParent.Controls.Add(context);

                // inject our replaced control where the TreeviewEx originally was

        /// <summary>
        /// Parses multiple source roots into discrete data context controls (e.g. 'dataSource=/sitecore/content|/sitecore/media library')
        /// </summary>
        /// <param name="originalDataContext">The original data context the base control generated. We reuse some of its property values.</param>
        /// <returns></returns>
        protected virtual DataContext[] ParseDataContexts(DataContext originalDataContext)
            return new ListString(DataSource).Select(x => CreateDataContext(originalDataContext, x)).ToArray();

        /// <summary>
        /// Creates a DataContext control for a given Sitecore path data source
        /// </summary>
        protected virtual DataContext CreateDataContext(DataContext baseDataContext, string dataSource)
            DataContext dataContext = new DataContext();
            dataContext.ID = GetUniqueID("D");
            dataContext.Filter = baseDataContext.Filter;
            dataContext.DataViewName = "Master";
            if (!string.IsNullOrEmpty(DatabaseName))
                dataContext.Parameters = "databasename=" + DatabaseName;
            dataContext.Root = dataSource;
            dataContext.Language = Language.Parse(ItemLanguage);

            return dataContext;
  1. Add source in template Datasource=sitecore/_content/_Site1/_Home/_Articles|sitecore/_content/_Site1/_Home/_Rewards

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.