Copied to clipboard

Flag this post as spam?

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


  • Steve 2 posts 71 karma points
    Jan 30, 2024 @ 11:24
    Steve
    0

    Tree Controller Being Ignored

    Hi,

    I have two Tree Controllers, one for Returns and another for Products. The Returns Tree Controller seems to work fine, and is shown in the CMS as a root node. But the Products Tree Controller is being ignored completely.

    Returns Tree Controller

    [PluginController("Returns")]
    [Tree("returns", "Returns", TreeTitle = "Returns", TreeGroup = "ReturnsGroup", SortOrder = 5, IsSingleNodeTree = false)]
    public class ReturnsController : TreeController
    {
        private readonly IEFCoreScopeProvider<CosworthContext> _efCoreScopeProvider;
        private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;
    
        public ReturnsController(IEFCoreScopeProvider<CosworthContext> efCoreScopeProvider,
            ILocalizedTextService localizedTextService,
            UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
            IMenuItemCollectionFactory menuItemCollectionFactory,
            IEventAggregator eventAggregator)
            : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
        {
            _efCoreScopeProvider = efCoreScopeProvider;
            _menuItemCollectionFactory = menuItemCollectionFactory ?? throw new ArgumentNullException(nameof(menuItemCollectionFactory));
        }
    
        protected override ActionResult<TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
        {        
            return new TreeNodeCollection();
        }
    
        protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
        {       
            return _menuItemCollectionFactory.Create();
        }
    
        protected override ActionResult<TreeNode> CreateRootNode(FormCollection queryStrings)
        {
            var route = string.Format("{0}/{1}/{2}", "Returns", "Returns", "list");
            return base.CreateTreeNode("Returns", null, queryStrings, "Returns", "icon-server", false, route);
        }
    }
    

    This creates the root menu item for Returns... enter image description here

    In the packages section in the CMS the Products section is here...

    enter image description here

    I then created another Tree Controller named Products which is being ignored. The constructor and the CreateRootNode method is never invoked.

        [PluginController("Products")]
    [Tree("products", "Products", TreeTitle = "Products", TreeGroup = "ProductsGroup", SortOrder = 6, IsSingleNodeTree = false)]
    public class ProductsController : TreeController
    {
        private readonly IEFCoreScopeProvider<CosworthContext> _efCoreScopeProvider;
        private readonly IMenuItemCollectionFactory _menuItemCollectionFactory;
    
        public ProductsController(IEFCoreScopeProvider<CosworthContext> efCoreScopeProvider,
            ILocalizedTextService localizedTextService,
            UmbracoApiControllerTypeCollection umbracoApiControllerTypeCollection,
            IMenuItemCollectionFactory menuItemCollectionFactory,
            IEventAggregator eventAggregator)
            : base(localizedTextService, umbracoApiControllerTypeCollection, eventAggregator)
        {
            _efCoreScopeProvider = efCoreScopeProvider;
            _menuItemCollectionFactory = menuItemCollectionFactory ?? throw new ArgumentNullException(nameof(menuItemCollectionFactory));
        }
    
        protected override ActionResult<TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
        {
            return new TreeNodeCollection();
        }
    
        protected override ActionResult<MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings)
        {
            return _menuItemCollectionFactory.Create();
        }
    
        protected override ActionResult<TreeNode> CreateRootNode(FormCollection queryStrings)
        {
            var route = string.Format("{0}/{1}/{2}", "Products", "Products", "list");
            return base.CreateTreeNode("Products", null, queryStrings, "Products", "icon-server", false, route);
        }
    }
    

    To elaborate further, I have added both Sections to a composer....

    public class SectionComposer : IComposer
    {
        public void Compose(IUmbracoBuilder builder)
        {
            builder.Sections().Append<ReturnsSection>().Append<ProductsSection>();
        }
    }
    

    Then called AddComposers() in the StartUp.cs file. The sections are being picked up as well.

    services.AddUmbraco(_env, _config)
        .AddBackOffice()
        .AddWebsite()
        .AddComposers()
        .AddCustomDBTables()
        .AddComposers()
        .Build();
    

    I am completely stuck and any help will be much appreciated!

  • 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