Copied to clipboard

Flag this post as spam?

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


  • Paul Sørensen 302 posts 648 karma points
    Dec 29, 2013 @ 19:42
    Paul Sørensen
    0

    New Action for Custom section in v7

    Hi 

    I have created a new Custom section in v7 following this http://www.enkelmedia.se/blogg/2013/11/22/creating-custom-sections-in-umbraco-7-part-1.aspx

    I have created a new action but it does not show up in the menu - also Refresh is not shown - Create appears as the only item in the menu. I have added the Letter of the new action to the default permission for Admin as I thought taht was the problem - but it still does not show up

    Any Ideas?

    /Paul S

  • Alexander 20 posts 70 karma points
    Dec 30, 2013 @ 17:41
    Alexander
    0

    Hi Paul!

    The first thing in my mind is to check that you have permissions to see this section in back office. Go to edit your admin user and at the bottom of the page you'll find checkbox list, make sure that appropriate section is checked.

     

    Second thing that I can advice you is to use TreeBase class instead of controller. It'll make code much easier. In our project we use only BaseTree class for this purposes, also it self-generate code for tree.config and so on.

    Here is example:

     

    Code:
    [Tree("trimirror", "tasks", "Tasks", ".sprTreeFolder", "sprTreeFolder_o", "", false, true, 1)]
        public class TasksTree : BaseTree
        {
    
            private readonly IGameTaskService _taskService = DependencyResolver.Current.GetService<IGameTaskService>();
    
            public TasksTree(string application) : base(application)
            {
    
            }
    
            #region BaseTree members
    
            public override void RenderJS(ref StringBuilder Javascript)
            {
                Javascript.Append("\r\nfunction openTask(id) {\r\n\tUmbClientMgr.contentFrame('surface/umbraco/EditTask/' + id);\r\n}\r\n");
            }
    
            public override void Render(ref XmlTree tree)
            {
                var tasks = _taskService.GetAll();
                if (tasks != null && tasks.Any())
                {
                    foreach (var task in tasks.OrderBy(x => x.Name))
                    {
                        XmlTreeNode node = XmlTreeNode.Create((BaseTree)this);
                        node.NodeID = task.Id.ToString();
                        node.Text = task.Name;
                        node.Action = "javascript:openTask('" + task.Id + "');";
                        node.Icon = "icon-script";
                        node.Menu = (List<IAction>)null;
                        this.OnBeforeNodeRender(ref tree, ref node, EventArgs.Empty);
                        if (node != null)
                            tree.Add(node);
                        this.OnAfterNodeRender(ref tree, ref node, EventArgs.Empty);
                    }
                }
            }
    
            protected override void CreateRootNode(ref XmlTreeNode rootNode)
            {
                rootNode.Text = ui.Text("Tasks");
                rootNode.NodeType = "init" + this.TreeAlias;
                rootNode.NodeID = "init";
                rootNode.Menu = new List<IAction>
                {
                    ActionRefresh.Instance
                };
            }
            #endregion

    Hope it will help you

  • Paul Sørensen 302 posts 648 karma points
    Dec 30, 2013 @ 20:14
    Paul Sørensen
    0

    Hi Alexander

    I have added the permission to the admin user in the DB since Administrator does not show up as a User Type - quess that's new in V7?

    My old sections are based on BaseTree and they work - I just wanted to do it the V7 way.

    I have spent a lot of time debugging the source for  v7 since the doc. is still appears to be very limited.

    /Paul S

  • Per Ploug 865 posts 3456 karma points MVP admin
    Jan 02, 2014 @ 15:09
Please Sign in or register to post replies

Write your reply to:

Draft