Unfortunately, the pipeline mentioned in the Adam Najmanowicz answer works for some other types, such as Droplink and Multilist, but the pipeline does not start for Droptree fields.
Having examined this more deeply, I found that the source of the Droptree IS field is using the wrong context element, as Adam mentioned, but the code comes from the Droptree field itself: -
Sitecore.Shell.Applications.ContentEditor.Tree, Sitecore.Kernel
Using the query string code from Adamβs answer, we can create a βfixedβ custom droptree field that is almost the same as a regular droptree, but will instead use the correct context element. The code inherits from the regular Tree control and only changes the way the Source property is set.
public class QueryableTree : Sitecore.Shell.Applications.ContentEditor.Tree {
The above code is almost the same as the Source property in the Tree field of the tree, except that we calculate the correct context element from the URL if we find that we are in the rendering options dialog box.
To create a custom field, you just need to edit the Web.Config file as described here . Then add the custom field to the base database as described here .
This means that now parameters can have queries for their source, which allows us to restrict the available elements to the content editor. (Useful for multisite solutions).
source share