Copied to clipboard

Flag this post as spam?

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


  • Bilal Haidar 144 posts 410 karma points
    Oct 21, 2014 @ 16:09
    Bilal Haidar
    0

    Infinite-level menu items in Tree

    Hi,

    I am following this article to create a custom section in Umbraco: http://www.enkelmedia.se/blogg/2013/11/22/creating-custom-sections-in-umbraco-7-part-1.aspx.

     

    This is the source code:

     [PluginController("CustomSection")]
        [Umbraco.Web.Trees.Tree("CustomSection", "CustomSectionTree", "My custom section", iconClosed: "icon-doc")]
        public class CustomSectionTreeController : TreeController
        {
            protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
            {
                var nodes = new TreeNodeCollection();
                var item = this.CreateTreeNode(id, "-1", queryStrings, "My item", "icon-truck", true);
                nodes.Add(item);
                return nodes;
    
            }
    
            protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
            {
                var menu = new MenuItemCollection();
                menu.DefaultMenuAlias = ActionNew.Instance.Alias;
                menu.Items.Add("Create");
                return menu;
            }
        }
    

     

    When rendered inside Umbraco back office, I am getting this:

    It keeps on adding sub items the more I expand. Any idea what might be going wrong?

     

    Thanks

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 21, 2014 @ 16:27
    Dennis Aaen
    0

    Hi Bilal,

    Have you looked into the comments of the blogpost that you are following for bulding this new section in the backoffice

    http://www.enkelmedia.se/blogg/2013/11/22/creating-custom-sections-in-umbraco-7-part-1.aspx

    To me it looks like that Alex Burr had the same problem as you are facing now, try to scroll down to the comments of the blogpost. then I think you will get a solution.

    I havenĀ“t try it myself, but hope this helps,

    /Dennis

  • Comment author was deleted

    Oct 21, 2014 @ 16:33

    Check https://github.com/TimGeyssens/UmbracoAngularBackofficePages/blob/master/UmbracoAngularBackofficePages/Trees/PeopleTreeController.cs for a more recent version, since that GetTreeNodes method will be called for each node you will a child node under each tree item, so first just check if you are rendering under the main root 

     

    if (id == Constants.System.Root.ToInvariantString())
     

    {

    ...

    }


  • Bilal Haidar 144 posts 410 karma points
    Oct 21, 2014 @ 16:34
    Bilal Haidar
    0

    True, seems problems no fully solved.

    Can you please refer me to an online resource that goes step by step on adding new custom section?

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft