Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • james 37 posts 121 karma points c-trib
    Feb 12, 2020 @ 11:25

    Moving trees to another section


    In Umbraco 7 we could move a tree to another section by updating the trees.config file. In v8 it looks like trees are now tied to a specific section via the Tree attribute on the tree's controller.

    I was looking at moving a tree by implementing a custom tree controller which inherited from the tree controller I want to move. My plan was to then remove the original tree from the tree collection builder and add my new tree, however the tree collection builder doesn't have a remove method (other collection builders, e.g. the dashboard collection builder, do have a Remove method). Even if this did work, it feels like a complicated way of doing something which was a simple config change before.

    Are we now unable to move trees in Umbraco 8, or should I be looking at a different approach here?

  • Bjarne Fyrstenborg 1275 posts 3921 karma points MVP 7x c-trib
    Dec 27, 2021 @ 19:01
    Bjarne Fyrstenborg

    I know this question was for Umbraco 8, but in Umbraco 9.1+ it is possible to remove a tree node using a composer and the RemoveTreeController() method.

    public class TreeComposer : IComposer
        public void Compose(IUmbracoBuilder builder)

    and then add a new tree controller inheriting ContentBlueprintTreeController, which is auto-registered because of the Tree attribute:

    [Authorize(Policy = AuthorizationPolicies.SectionAccessContent)]
    [Tree(Constants.Applications.Content, Constants.Trees.ContentBlueprints)]
    public class ContentTemplatesController : ContentBlueprintTreeController
        public ContentTemplatesController(
            ILocalizedTextService localizedTextService,
            UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
            IMenuItemCollectionFactory menuItemCollectionFactory,
            IContentService contentService,
            IContentTypeService contentTypeService,
            IEntityService entityService,
            IEventAggregator eventAggregator) 
            : base(localizedTextService, umbracoApiControllerTypeCollection, menuItemCollectionFactory, 
                    contentService, contentTypeService, entityService, eventAggregator)
        protected override ActionResult<TreeNode> CreateRootNode(FormCollection queryStrings)
            return base.CreateRootNode(queryStrings);

    I may also be possible to inject the tree using TreeNodesRenderingNotification: and in v8 TreeNodesRendering event:

    Before Umbraco 9.1 you could use TreeNodesRendering (v8) and TreeNodesRenderingNotification (v9) to remove/hide a specific tree.

    I have also suggested Content Templates should be added to content tree as content editors also need to edit and delete these, but we don't want to grant them full accesss to settings section:

    Maybe it should even be a granular permission per user group.

Please Sign in or register to post replies

Write your reply to: