Enjoyed this post?
Be sure to subscribe to the nopAccelerate newsletter and get regular updates about awesome posts just like this one and more!
If you’re a nopCommerce developer, you’ll find yourself using nopCommerce plugins to add your custom features into the nopCommerce. While nopCommerce IAdminMenuPlugin doesn’t allow to add your custom menu items under its default menu items, you can still add your custom menu items into Plugins menu.
In nopCommerce, administration menu is build from the Sitemap.Configuration file which is located in Nop.Admin folder. To add your custom menu items in nopCommerce administration panel, you can add it by extending SitemapNode class of nopCommerce.
To do the same, you can use following sample code which you need to add in your plugins’ cs file, after your plugin’s Install and Uninstall method.
public bool Authenticate() { return true; } public SiteMapNode BuildMenuItem() // SiteMapNode is Class in Nop.Web.Framework.Menu { var menuItemBuilder = new SiteMapNode() { Title = "Title For Menu item", // Title for your Custom Menu Item Url = "Path of action link", // Path of the action link Visible = true, RouteValues = new RouteValueDictionary() { {"Area", "Admin"} } }; var SubMenuItem = new SiteMapNode() // add child Custom menu { Title = "Title For Menu Chile menu item", // Title for your Sub Menu item ControllerName = "Your Controller Name", // Your controller Name ActionName = "Configure", // Action Name Visible = true, RouteValues = new RouteValueDictionary() { {"Area", "Admin"} }, }; menuItemBuilder.ChildNodes.Add(SubMenuItem); return menuItemBuilder; }In the above code, you can find comments where you need to replace values depending on your requirements. Moreover, the above code also explains how you can add a child menu items inside main menu.
Note that this code is tested to work on nopCommerce 3.40. Moreover, if you find any issue or need help, feel free to post it into comments or use nopCommerce forum.
One Comment
define steps to add custom manu and child menu i am biggner for Nopcommerce