Open Plugin menu item when on plugin page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 1 año
Hello,

I've created a few plugins for my site now and one thing i seem to be unable to understand is how to get the menu item in the sidebar to open when I'm on the plugin's page.

For example, I have two plugins under the sales menu item. The links take the user to the right page but the menu does not open and highlight that item when I'm on that page.

What do I have to add to the plugin code to have this functionality work?

Thanks,
Dan
Hace 1 año
it keep open by matching by system name
at html:
@{
    //page title
    ViewBag.PageTitle = T("Admin.YourPageTitle").Text;
    //active menu item (system name)
    NopHtml.SetActiveMenuItemSystemName("Third party plugins");
}

at plugin backend code:
 public class CustomPlugin : BasePlugin, IAdminMenuPlugin
{

    public Task ManageSiteMapAsync(SiteMapNode rootNode)
    {
        var menuItem = new SiteMapNode()
        {
            SystemName = "YourCustomSystemName",
            Title = "Plugin Title",
            ControllerName = "ControllerName",
            ActionName = "List",
            IconClass = "far fa-dot-circle",
            Visible = true,
            RouteValues = new RouteValueDictionary() { { "area", AreaNames.Admin } },
        };
        var pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Third party plugins");
        if(pluginNode != null)
            pluginNode.ChildNodes.Add(menuItem);
        else
            rootNode.ChildNodes.Add(menuItem);

        return Task.CompletedTask;
    }
}

ref: https://docs.nopcommerce.com/en/developer/plugins/menu-item.html
Hace 1 año
Perfect, just needed that little snippet for the view.

Perhaps you/they could update the article you sent me to include that?

Thanks!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.