2

I am looking to add a source to the Droptree field. This is working fine, but the issue is that it allows all the templates under the home item to be added. But I want to limit it to only items which have this Template ID {BC5A3B05-FB72-4DF5-A3A5-D5EEFF51D672} as a base template.

Please note that I am looking to filter base on the base template of the item. I know I can query based on the template itself but I don't know if there is an out of the box way to query on base template.

enter image description here

1
2

It doesn't exist OOTB to filter base on the base template of the item.

You need to check the class Sitecore.Shell.Applications.ContentEditor.Tree

the Source method

    /// <summary>Gets or sets the source.</summary>
    /// <value>The source.</value>
    public string Source
    {
      get => StringUtil.GetString(this._source);
      set
      {
        Assert.ArgumentNotNull((object) value, nameof (value));
        if (!value.StartsWith("query:", StringComparison.InvariantCulture))
        {
          this._source = value;
        }
        else
        {
          Item obj1 = Client.ContentDatabase.GetItem(this.ItemID);
          if (obj1 == null)
            return;
          Item obj2 = obj1.Axes.SelectSingleItem(value.Substring("query:".Length));
          if (obj2 == null)
            return;
          this._source = obj2.ID.ToString();
        }
      }
    }

The problem is Sitecore Query Syntax doesn't support filtering based on base template:

https://doc.sitecore.com/SdnArchive/Reference/Using%20Sitecore%20Query/Sitecore%20Query%20Syntax.html

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.