如何在NopCommerce 3.8中现有菜单下的管理面板中添加子菜单? [英] How can I add a submenu in admin panel under a existing menu in NopCommerce 3.8?

查看:143
本文介绍了如何在NopCommerce 3.8中现有菜单下的管理面板中添加子菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题几乎与此类似问题除了一点点变化.有一种添加菜单的解决方案,就像我也想添加菜单,但过程不同.

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.

目前,我正在开发有关组合促销优惠的项目.因此,因此我想像其他所有子菜单一样在Promotion下添加一个子菜单图像

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

但是我开发的是创建一个名为Plugins的单独菜单,并在其中添加一个子菜单.像这样的图像

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);
        }

我想知道应该从哪个SystemName添加此子菜单?

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

推荐答案

您可以使用:

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);
}

您要查找的系统名称是

促销

更新后的答案显示可以使用menuItem对象中的IconClass在菜单项名称之前添加图标.

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

为了完整起见,请不要忘记将IAdminMenuPlugin添加到插件CS文件中,如下所示:

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

public class MyCustomPlugin : BasePlugin, IAdminMenuPlugin

这篇关于如何在NopCommerce 3.8中现有菜单下的管理面板中添加子菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆