How can I add a submenu in admin panel under a exi

2019-07-26 11:29发布

问题:

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",
       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