Copied to clipboard

Flag this post as spam?

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


  • nickornotto 397 posts 900 karma points
    Jul 10, 2019 @ 19:04
    nickornotto
    0

    Trouble disaplying custom section in Umbraco 7.6

    I am trying to build a new section in Umbraco 7.6.

    I had this working the 'old' way that use the tree controller extending from BaseTree but it was very ugly.

    I'm now trying to do it using TreeController. I have followed the tutorials by:

    1. Kevin Giszewski (https://github.com/kgiszewski/LearnUmbraco7/blob/master/Chapter%2016%20-%20Custom%20Sections%2C%20Trees%20and%20Actions/01%20-%20Create%20a%20Section.md)

    2. and another by Tim Geyssens (https://github.com/TimGeyssens/UmbracoAngularBackofficePages)

    but all I'm getting is an empty section without the tree and just with the title:

    enter image description here

    The controllers are not even hit on debugging, no console errors, no 500 errors, all compiles fine too.

    Here's my code:

    trees.config:

    <add initialize="true" sortOrder="0" alias="UmbracoBookshelfTree" application="UmbracoBookshelf" title="Umbraco Bookshelf" iconClosed="icon-folder"
        iconOpen="icon-folder-open" type="UmbracoBookshelf.Controllers.UmbracoBookshelfTreeController, MyWebsite.Backoffice"/>
    

    applications.config:

    <add alias="UmbracoBookshelf" name="Umbraco Bookshelf" icon="icon-globe-inverted-america" sortOrder="5"/>
    

    Section:

    using umbraco.businesslogic;
    using umbraco.interfaces;
    
    namespace UmbracoBookshelf.Applications
    {
        [Application("UmbracoBookshelf", "Umbraco Bookshelf", "icon-globe-inverted-america", 5)]
        public class UmbracoBookshelfApplication : IApplication
        {
        }
    }
    

    Tree controller:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net.Http.Formatting;
    using System.Web;
    using umbraco;
    using umbraco.BusinessLogic.Actions;
    using Umbraco.Core;
    using Umbraco.Web.Models.Trees;
    using Umbraco.Web.Mvc;
    using Umbraco.Web.Trees;
    
    namespace UmbracoBookshelf.Controllers
    {
        [PluginController("UmbracoBookshelf")]
        [Umbraco.Web.Trees.Tree("UmbracoBookshelf", "UmbracoBookshelfTree", "Umbraco Bookshelf", iconClosed: "icon-folder")]
        public class UmbracoBookshelfTreeController : TreeController
        {
    
            protected override Umbraco.Web.Models.Trees.MenuItemCollection GetMenuForNode(string id, System.Net.Http.Formatting.FormDataCollection queryStrings)
            {
                var menu = new MenuItemCollection();
    
                if (id == Constants.System.Root.ToInvariantString())
                {
                    // root actions              
                    menu.Items.Add<CreateChildEntity, ActionNew>(ui.Text("actions", ActionNew.Instance.Alias));
                    menu.Items.Add<RefreshNode, ActionRefresh>(ui.Text("actions", ActionRefresh.Instance.Alias), true);
                    return menu;
                }
                else
                {
                    //menu.DefaultMenuAlias = ActionDelete.Instance.Alias;
                    menu.Items.Add<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias));
    
                }
                return menu;
            }
    
            protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
            {
                var nodes = new TreeNodeCollection();
    
                nodes.Add(CreateTreeNode("123", "456", queryStrings, "Some name to be shown"));
                nodes.Add(CreateTreeNode("789", "456", queryStrings, "Some other name to be shown"));
    
                return nodes;
            }
        }
    }
    

    It's pretty simple, what could wrong here?

Please Sign in or register to post replies

Write your reply to:

Draft