Copied to clipboard

Flag this post as spam?

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


  • Lucas Chasteen 24 posts 92 karma points
    Dec 22, 2015 @ 17:40
    Lucas Chasteen
    0

    Adding a custom node to core tree

    Hello!

    I'm looking in to adding a custom node to a core tree, in this case a Tags node to the Content tree.

    As I see it, there are a couple of way this can potentially work:

    1: Use the TreeControllerBase.TreeNodesRendering event to run something like this:

    void AddTagsToContentTree(TreeControllerBase sender, TreeNodesRenderingEventArgs e)
    {
        var node = sender.CreateTreeNode("-600", "-1", qs, "Tags", "icon-tag",  false, route);
        e.Nodes.Add(node);
    }
    

    enter image description here

    In this option, I'm able to render the node (and get child nodes to populate) with the first option, but I am completely unable to override any routing, so I am unable to implement any desired logic.

    I would have figured using the newly created node's routePath property would have had some benefit for me, but all I can manage is to get it to route to something custom within /umbraco/views/[etc] by using something like:

        routePath = "backoffice/TagEditor/tags";
    

    2: Add a custom tree housed within the Content application:

        [PluginController("TagEditor")]
        [Tree("content", "tageditor", "Tags", iconClosed: "icon-tag")]
        public class TagEditorTreeController : TreeController
    

    enter image description here

    In the second option, I'm able to route to my desired controllers/views and implement the logic I require but I don't want to add the extra folder layer to the content tree (specifically Home etc under the folder).


    I was hoping I could perhaps mix both methods adding the new node to Content but have it use the routing/behavior of the custom tree controller.

    Does anyone have any insight on this or am I just barking up the wrong tree altogether?

    Edit: I should note that this is slightly related to the following issue on YouTrack, that's hasn't seen much action: U4-6617: v7 Custom Tree Routing is Confusing and Doesn't Allow for Specific URL's

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies