Copied to clipboard

Flag this post as spam?

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


  • Peter 24 posts 102 karma points
    Jan 11, 2017 @ 09:28
    Peter
    0

    How to create nodes in a new section

    Hi

    I need to create a new section in the left main menu. At the moment I have created a folder in the App_Plugins – and added (amongst other things) a TreeController with 3 TreeNodes (see attached image).

    My question/problems is – each of those 3 TreeNodes (which I have created manually in the TreeController) needs to have some children which should be stored in db. How do I do that? Should I do it through the ContentService (eventhough it is not content – and should not have a public URL)?

    enter image description hereAny place I can read about this?

  • NDDT 68 posts 240 karma points c-trib
    Jan 11, 2017 @ 10:22
    NDDT
    0

    You could add your own database-table via peta-poco. It's easy to find examples.

  • Peter 24 posts 102 karma points
    Jan 12, 2017 @ 06:36
    Peter
    0

    I was a bit in doubt if I should somehow save them in the umbracoNode table - but you would recommend to create their own table using peta-poco?

  • NDDT 68 posts 240 karma points c-trib
    Jan 12, 2017 @ 07:44
    NDDT
    0

    I have used petapoco in the past.

    It's probaply possible to save them as umbraco-nodes, but then they would also be displayed in the content-section and editors would be able to change them. Also you can add meta-data like id's, to create a hierarchy, without displaying them to the users.

    You have to create an editor for your custom-section anyway. I don't think it's possible to reuse the one from the content section.

  • Aki 43 posts 214 karma points
    Jan 11, 2017 @ 10:42
    Aki
    0

    its answered her https://our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/49909-Custom-Section-Custom-dynamic-Treenodes-Custom-Node-Content

    By Thomas Beckert

    namespace UmbMyApp
    

    {

    [Application("myAppName", "myAppName", "icon-car", 15)]
    public class myApplication : IApplication { }
    
    [PluginController("myAppName")]
    [Umbraco.Web.Trees.Tree("myAppName", "myAppNameTree", "myAppName Section", iconClosed: "icon-doc")]
    public class myAppTreeController : TreeController
    {
        String[] sectionNodes = { "myAppNameNode1", "myAppNameNode2", "myAppNameNode2", "myAppNameNode4" };
        String[] nlSectionNodes = { "Subnode1" ,"Subnode2", "Subnode3" };
    
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
    
            if (id == global::Umbraco.Core.Constants.System.Root.ToInvariantString())
            {
                var tree = new TreeNodeCollection();
                tree.Add(CreateTreeNode(sectionNodes[0], id, queryStrings, sectionNodes[0], "icon-calendar-alt", true));
                tree.Add(CreateTreeNode(sectionNodes[1], id, queryStrings, sectionNodes[1], "icon-calendar-alt", true));
                tree.Add(CreateTreeNode(sectionNodes[2], id, queryStrings, sectionNodes[2], "icon-calendar-alt", true));
                tree.Add(CreateTreeNode(sectionNodes[3], id, queryStrings, sectionNodes[3], "icon-calendar-alt", true));
    
                return tree;
            }
    
    
            //create Childnodes for Treenode myAppNameNode1
            if (id == sectionNodes[0])
            {
                var tree = new TreeNodeCollection();
                tree.Add(CreateTreeNode(nlSectionNodes[0], id, queryStrings, nlSectionNodes[0], "icon-globe-alt", false));
                tree.Add(CreateTreeNode(nlSectionNodes[1], id, queryStrings, nlSectionNodes[1], "icon-globe-alt", false));
                tree.Add(CreateTreeNode(nlSectionNodes[2], id, queryStrings, nlSectionNodes[2], "icon-globe-alt", false));     
    
                return tree;
            }
    
            //this tree doesn't suport rendering more than 1 level
            throw new NotSupportedException();
        }
    }
    

    }

  • 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