Copied to clipboard

Flag this post as spam?

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


  • Gopinath 11 posts 50 karma points
    Apr 17, 2014 @ 08:36
    Gopinath
    0

    How to create a custom section in Umbraco 6 and above?

    I need to create a custom section in umbraco 6. I've seen many references like,

    http://adaodeveloper.blogspot.in/2013/01/create-new-custom-section-in-umbraco-48.html

    http://our.umbraco.org/forum/developers/extending-umbraco/46141-How-to-create-a-custom-BaseTree-tree

    nothing works, I found a similar question in stackoverflow,

    How to create a Custom section in admin panel of umbraco 6?

    but the link provided as an answer is not loading.

    Many blogs says, the method of creating custom sections in older versions of umbraco. That doesn't work on umbraco 6.

    Can anyone help me with this.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 17, 2014 @ 10:32
  • Gopinath 11 posts 50 karma points
    Apr 17, 2014 @ 11:21
    Gopinath
    0

    Thanks for the reply. I've tried those links too, but that doesn't work on umbraco 6 and above. It works well in umbraco 4+.

  • Tim Anderson 20 posts 83 karma points
    Apr 24, 2014 @ 14:23
    Tim Anderson
    1

    Hi,

    When learning how to create custom sections in Umbraco 6 I found the following two blog posts rather helpful in regards to that matter...

    http://www.robertgray.net.au/2011/5/10/creating-a-custom-content-tree-in-umbraco

    and

    http://www.robertgray.net.au/posts/2011/5/creating-custom-multi-level-trees-in-umbraco#.U1j9FPm2h8H

    the same author also posted all his code on GitHub which was extremely useful for me in understanding how everything fitted together: https://github.com/robgray/f1speedguides/tree/master/src/atomicf1/cms/presentation

    While the content does refer to Umbraco 4.x and mentions the umbracoApp and umbracoAppTree tables like some of the above examples, these have now been moved to config files within the config directory and can be automatically populated by your application and tree classes by using the Application and Tree attributes to decorate the class (as referenced by theoutfield.net example.

    The following two code samples should create an application and a tree in Umbraco6 - from this you should be able to expand using the numerous examples above.

    For Application class

    [Application("myApplication", "My Application", "icon.jpg", 0)]
    public class MyApplication : IApplication { }
    

    and for Tree class

    [Tree("myApplication", "myApplicationTree", "My Application", FolderIcon, FolderIconOpen, "", false, true, 0)]
    public class MyTree: BaseTree
    {
        public MyTree(string application) : base(application) {}
    
        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            rootNode.Text = "My Tree";
            rootNode.Icon = FolderIcon;
            rootNode.OpenIcon = FolderIconOpen;
            rootNode.NodeType = TreeAlias;
            rootNode.Menu = new List<IAction>() { ActionRefresh.Instance };
        }
    
        public override void Render(ref XmlTree tree)
        {
            foreach(int i=0; i<5; i++)
            {
                var treeNode = XmlTreeNode.Create(this);
                treeNode.NodeID = i.ToString();
                treeNode.Text = String.Format("Item {0}", i);
                treeNode.Icon = FolderIcon;
                treeNode.OpenIcon = FolderIconOpen;
                treeNode.Action = String.Format("javascript: UmbClientMgr.contentFrame('Plugins/MyPages/MyPage.aspx?Id={0}');", i);
                treeNode.Menu = new List<IAction>() { ActionRefresh.Instance };
                tree.Add(treeNode);
            }
        }
    
        public override void RenderJS(ref StringBuilder Javascript)
        {
            // Add any javascript needed here...
        }
    }
    

    I hope that helps...

    Kind regards,

    Tim

  • Graham 6 posts 25 karma points
    Aug 22, 2014 @ 15:23
    Graham
    0

    Thank you Tim! The declaration on the MyTree class is exactly what I was missing!

  • Graham 6 posts 25 karma points
    Aug 26, 2014 @ 11:50
    Graham
    0

    On the custom tree, how can I hide the context menu? Some posts have said to use node.Menu.Clear() which kind of works, it removes an item from the menu, but when I right click on the node I get an empty context menu still. How can I hide that? 

Please Sign in or register to post replies

Write your reply to:

Draft