How can I add a submenu in admin panel under a existing menu in NopCommerce 3.8?

£可爱£侵袭症+ 提交于 2019-12-11 04:14:45

问题


My question is almost similar like this question except a little bit change. There is a solution for adding menu, like I also want to add menu but in a different process.

Currently I am developing a project on combo promotional offer. So therefore I want to add a sub menu under Promotion Like all other submenus image

But what I have developed is creating a separate menu named Plugins and adding a submenu there. Like this image

And here is the code I have used for creating that menu.

public void ManageSiteMap(SiteMapNode rootNode)
        {
            var menuItem = new SiteMapNode()
            {
                SystemName = "Promotion.Combo",
                Title = "Combo Offer",
                ControllerName = "PromotionCombo",
                ActionName = "Configure",
                Visible = true,
                RouteValues = new RouteValueDictionary() { { "area", null } },
            };
            var pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Third party plugins");
            if (pluginNode != null)
                pluginNode.ChildNodes.Add(menuItem);
            else
                rootNode.ChildNodes.Add(menuItem);
        }

I would like to know from which SystemName shall I add this submenu?


回答1:


You can use:

public void ManageSiteMap(SiteMapNode rootNode)
{
    var menuItem = new SiteMapNode()
    {
       SystemName = "Promotion.Combo",
       Title = "Combo Offer",
       ControllerName = "PromotionCombo",
       ActionName = "Configure",
       IconClass = "fa-dot-circle-o"
       Visible = true,
       RouteValues = new RouteValueDictionary() { { "area", null } },
    };

    var pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Promotions");
        if (pluginNode != null)
            pluginNode.ChildNodes.Add(menuItem);
        else
            rootNode.ChildNodes.Add(menuItem);
}

System name you looked for is

Promotions

Updated answer to show you can use the IconClass in your menuItem object to add the icon in front of the menu item name.

Also, just for completeness, don't forget to add IAdminMenuPlugin to your plugin cs file, like so:

public class MyCustomPlugin : BasePlugin, IAdminMenuPlugin


来源:https://stackoverflow.com/questions/41583629/how-can-i-add-a-submenu-in-admin-panel-under-a-existing-menu-in-nopcommerce-3-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!