Admin plugin item

4 years ago
Hi,
I can't really find the answer online. So I'll do a little post: I'm new to Nopcommerce just installed 3.8 first all congrats to the team really nice job, the new admin layout was just what nc needed.

so I wanted to install my own made plugins in the 3.80 and it turns out that the submenus suddenly don't work any more. I had a look at the code and it seems good to me aso I had no changes in the code and in version 3.6 everything worked fine.

I tried to look for references of classes that implented the:  SiteMapNode class but for some reason I can't seem to find one.

Could some one have a look at this, what I'm I missing here?

        #region MenuItems Aanmaken.
        public SiteMapNode BuildMenuItem()
        {
            var parentNode = new SiteMapNode()
            {
                Visible = true,
                Title = "Mailing System",
                Url = "/PHMailingSystem/Campaigns",
                RouteValues = new RouteValueDictionary(){{"Area","Admin"}}
            };

            #region Campaigns
                var campaigns = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Campaigns",
                    Url = "/PHMailingSystem/Campaigns"
                };

                var createNewCampaign = new SiteMapNode()
                {
                    Visible = true,
                    Title = "New email campaign",
                    Url = "/PHMailingSystem/Settings"
                };
                var listCampaign = new SiteMapNode()
                {
                    Visible = true,
                    Title = "All campaigns",
                    Url = "/PHMailingSystem/Campaigns"
                };

                campaigns.ChildNodes.Add(createNewCampaign);
                campaigns.ChildNodes.Add(listCampaign);
            #endregion


            #region Templates
            var templates = new SiteMapNode()
                {
                    Visible = true,
                    Title = "E-Mail templates",
                    Url = "/PHMailingSystem/Templates"
            };
                var createTemplate = new SiteMapNode()
                {
                    Visible = true,
                    Title = "New template",
                    Url = "/PHMailingSystem/Template"
                };
                var listTemplates = new SiteMapNode()
                {
                    Visible = true,
                    Title = "All templates",
                    Url = "/PHMailingSystem/Templates"
                };

                templates.ChildNodes.Add(createTemplate);
                templates.ChildNodes.Add(listTemplates);
            #endregion


            #region GeneralSettings
                var generalsettings = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Settings",
                    Url = "/PHMailingSystem/GeneralSettings"
                };
            #endregion

            #region Help
                var help = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Help",
                    Url = "#"
                };
                var about = new SiteMapNode()
                {
                    Visible = true,
                    Title = "About",
                    Url = "/PHMailingSystem/About"
                };
                var manual = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Manuals",
                    Url = "/PHMailingSystem/Manuals"
                };

                help.ChildNodes.Add(about);
                help.ChildNodes.Add(manual);
            #endregion


            parentNode.ChildNodes.Add(campaigns);
            parentNode.ChildNodes.Add(templates);
            parentNode.ChildNodes.Add(generalsettings);
            parentNode.ChildNodes.Add(help);

            return parentNode;
        }

        /// <summary>
        /// Voor de menu-items die in BuildMenuItem werden aangemaakt toe te voegen aan het Menu en standaard mailing systeem niet meer te tonen.
        /// </summary>
        /// <param name="rootNode"></param>
        public void ManageSiteMap(SiteMapNode rootNode)
        {

            rootNode.ChildNodes.Add(BuildMenuItem());
        }
        #endregion
4 years ago
I hope you have implemented IAdminMenuPlugin interface? :)
4 years ago
Yes I did,
the problem is my childNodes are not visible anymore.  

I only see the parentnode.
4 years ago
[email protected] wrote:
Yes I did,
the problem is my childNodes are not visible anymore.  

I only see the parentnode.



Please inspect the browser Dom is created there or not.
4 years ago
I had the same issue, all ok in 3.70 but in 3.80 the child menu items are gone. Apparently this is because the URL of the parent Item is not empty/blank

var parentNode = new SiteMapNode()
            {
                Visible = true,
                Title = "Mailing System",
                Url = "/PHMailingSystem/Campaigns",
                RouteValues = new RouteValueDictionary(){{"Area","Admin"}}
            };

So, remove URL="/PHMailingSystem/Campaigns" from the parent and -according to my tests- the children will show.
3 years ago
Hi Caerels

I Have same issue.. but after changes as u suggest in ur post its working fine.... thanks
3 years ago
NopDevelop2017 wrote:
Hi,
I can't really find the answer online. So I'll do a little post: I'm new to Nopcommerce just installed 3.8 first all congrats to the team really nice job, the new admin layout was just what nc needed.

so I wanted to install my own made plugins in the 3.80 and it turns out that the submenus suddenly don't work any more. I had a look at the code and it seems good to me aso I had no changes in the code and in version 3.6 everything worked fine.

I tried to look for references of classes that implented the:  SiteMapNode class but for some reason I can't seem to find one.

Could some one have a look at this, what I'm I missing here?

        #region MenuItems Aanmaken.
        public SiteMapNode BuildMenuItem()
        {
            var parentNode = new SiteMapNode()
            {
                Visible = true,
                Title = "Mailing System",
                Url = "/PHMailingSystem/Campaigns",
                RouteValues = new RouteValueDictionary(){{"Area","Admin"}}
            };

            #region Campaigns
                var campaigns = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Campaigns",
                    Url = "/PHMailingSystem/Campaigns"
                };

                var createNewCampaign = new SiteMapNode()
                {
                    Visible = true,
                    Title = "New email campaign",
                    Url = "/PHMailingSystem/Settings"
                };
                var listCampaign = new SiteMapNode()
                {
                    Visible = true,
                    Title = "All campaigns",
                    Url = "/PHMailingSystem/Campaigns"
                };

                campaigns.ChildNodes.Add(createNewCampaign);
                campaigns.ChildNodes.Add(listCampaign);
            #endregion


            #region Templates
            var templates = new SiteMapNode()
                {
                    Visible = true,
                    Title = "E-Mail templates",
                    Url = "/PHMailingSystem/Templates"
            };
                var createTemplate = new SiteMapNode()
                {
                    Visible = true,
                    Title = "New template",
                    Url = "/PHMailingSystem/Template"
                };
                var listTemplates = new SiteMapNode()
                {
                    Visible = true,
                    Title = "All templates",
                    Url = "/PHMailingSystem/Templates"
                };

                templates.ChildNodes.Add(createTemplate);
                templates.ChildNodes.Add(listTemplates);
            #endregion


            #region GeneralSettings
                var generalsettings = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Settings",
                    Url = "/PHMailingSystem/GeneralSettings"
                };
            #endregion

            #region Help
                var help = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Help",
                    Url = "#"
                };
                var about = new SiteMapNode()
                {
                    Visible = true,
                    Title = "About",
                    Url = "/PHMailingSystem/About"
                };
                var manual = new SiteMapNode()
                {
                    Visible = true,
                    Title = "Manuals",
                    Url = "/PHMailingSystem/Manuals"
                };

                help.ChildNodes.Add(about);
                help.ChildNodes.Add(manual);
            #endregion


            parentNode.ChildNodes.Add(campaigns);
            parentNode.ChildNodes.Add(templates);
            parentNode.ChildNodes.Add(generalsettings);
            parentNode.ChildNodes.Add(help);

            return parentNode;
        }

        /// <summary>
        /// Voor de menu-items die in BuildMenuItem werden aangemaakt toe te voegen aan het Menu en standaard mailing systeem niet meer te tonen.
        /// </summary>
        /// <param name="rootNode"></param>
        public void ManageSiteMap(SiteMapNode rootNode)
        {

            rootNode.ChildNodes.Add(BuildMenuItem());
        }
        #endregion
3 years ago
Hi  
    we  create  sitemap node in admin area ,
    but i am  Not add sub menu  item node   and  side map ,
  

public void ManageSiteMap(Web.Framework.Menu.SiteMapNode rootNode)
        {

          

            #region
            var pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Easypost.SideNode");
            if (pluginNode != null)
            {

                var parentNode = new Web.Framework.Menu.SiteMapNode() // this one is showing only
                {
                    //SystemName = "Widgets.PromoSlider",
                    Title = "orderitem",
                    ControllerName = "order",
                    ActionName = "LIst",
                    Visible = true,
              RouteValues = new RouteValueDictionary() { { "area", null } }
                };

                parentNode.ChildNodes.Add(new Web.Framework.Menu.SiteMapNode()
                {
                    Title = "shipment",
                    // Title for your Sub Menu item
                    ControllerName = "order", // Your controller Name
                    ActionName = "Shipment", // Action Name
                    Visible = true,
                    RouteValues = new RouteValueDictionary() { { "systemName", this.PluginDescriptor.SystemName } },
                });
                parentNode.ChildNodes.Add(new Web.Framework.Menu.SiteMapNode()
                {
                    SystemName = "Easypost.SideNode",
                    Title = "Edit",
                    ControllerName = "order",
                    ActionName = "Edit",
                    Visible = true,
                    RouteValues = new RouteValueDictionary() { { "Namespaces", "Nop.Plugin.Easypost.SideNode.Controllers" }, { "area", null } }
                });


                pluginNode.ChildNodes.Add(parentNode);




  please  Help
2 years ago
Solution
I also tried to add via add method, but didnt work.
In 3.90 I did it like this. Works perfect.

public void ManageSiteMap(SiteMapNode rootNode)
        {
            var menuItem = new SiteMapNode()
            {
                SystemName = "Bootproject",
                Title = "Bootproject",
                Visible = true,
                IconClass = "fa-cube",
                RouteValues = new RouteValueDictionary() { { "area", null } },
                ChildNodes =
                {
                    new SiteMapNode()
                    {
                        SystemName = "Content Page",
                        Title = "Content page",
                        ControllerName = "ThemePage",
                        ActionName = "List",
                        Visible = true,
                        IconClass = "fa-dot-circle-o",
                        RouteValues = new RouteValueDictionary() { { "area", "admin" } },
                    }

                }
            };

            var pluginNode = rootNode.ChildNodes;
            pluginNode.Add(menuItem);
2 years ago
Can you share your code snippet, so can check with code.

You need to fix for nopCommerce-4.00, right?