How to keep Admin sidebar-menu when displaying view from new Admin menu option

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hello,

I'm using nopCommerce 3.90 with source.

I created a plugin that adds a menu option to the end of the Admin menu.  When it executes the method called by the new menu option, the admin sidebar-menu disappears and all of the other text on the screen as well.  My view text appears, but on one big blank screen.

How do I allow my view to display without losing the rest of the Admin screen with all of the menu options etc.?

Here is my Plugin:
using Nop.Core.Plugins;
using Nop.Services.Common;
using Nop.Web.Framework.Menu;
using System;
using System.Linq;
using System.Web.Routing;

namespace Nop.Plugin.Misc.LakesideImport
{
     public class LakesideImportPlugin : BasePlugin, IMiscPlugin, IAdminMenuPlugin
     {
          public void ManageSiteMap(SiteMapNode rootNode)
          {
               var menuItem = new SiteMapNode()
               {
                    SystemName = "Misc.LakesideImport",
                    Title = "Lakeside Import",
                    ControllerName = "LakesideImport",
                    ActionName = "ImportProductFile",
                    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);

               //throw new NotImplementedException();
          }

          public override void Install()
          {
               base.Install();
          }

          public override void Uninstall()
          {
               base.Uninstall();
          }

          public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
          {
               actionName = "Configure";
               controllerName = "LakesideImport";
               routeValues = new RouteValueDictionary { { "Namespaces", "Nop.Plugin.Misc.LakesideImport.Controllers" }, { "area", null } };

               //throw new NotImplementedException();
          }
     }
}


Here is my Controller:
using Nop.Web.Framework.Controllers;
using System.Web.Mvc;

namespace Nop.Plugin.Misc.LakesideImport.Controllers
{
    [AdminAuthorize]
    public class LakesideImportController : BasePluginController
    {
          public ActionResult Configure()
          {
               return View("~/Plugins/Misc.LakesideImport/Views/MiscLakesideImport/Configure.cshtml");
          }

          public virtual ActionResult ImportProductFile()
          {
               return View("~/Plugins/Misc.LakesideImport/Views/MiscLakesideImport/ImportProductFile.cshtml");
          }
     }
}


Here is my View:
@{
    Layout = "";
}
<div class="panel-group">
    <div class="panel panel-default">
        <div class="panel-body">
     <p>
     You have reached the start screen for the Lakeside Import of ProductFile.
     </p>
        </div>
    </div>
</div>


Any help that anyone can provide would be gratefully appreciated.

Thanks,
Tony
6 years ago
Change the layout in your view to this:

Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
6 years ago
Thanks Adam.

That fixed it.

My new top level entry in the admin menu appears as "Plugins".

Is there a way to change that?

Thanks again,

Tony
6 years ago
The locale resource you're referring to is possibly "Admin.Plugins".  Also, check out Nop.Admin/sitemap.config.

Hope that helps!
6 years ago
AdamK wrote:
The locale resource you're referring to is possibly "Admin.Plugins".  Also, check out Nop.Admin/sitemap.config.


Adam,

I found this in the Nop.Admin/sitemap.config file:
<siteMapNode SystemName="Third party plugins" nopResource="Admin.Plugins" IconClass="fa-bars" />


I don't see how that helps me.

As far as the "locale resource", are you referring to this file: "C:\Users\Tony\Documents\Visual Studio 2017\Projects\Lakeside390\Presentation\Nop.Web\App_Data\Localization\defaultResources.nopres.xml".

Should I change that file?

<LocaleResource Name="Admin.Plugins">
    <Value>Plugins</Value>
  </LocaleResource>


Thanks,
Tony
6 years ago
Carneno wrote:
The locale resource you're referring to is possibly "Admin.Plugins".  Also, check out Nop.Admin/sitemap.config.

Adam,

I found this in the Nop.Admin/sitemap.config file:
<siteMapNode SystemName="Third party plugins" nopResource="Admin.Plugins" IconClass="fa-bars" />


I don't see how that helps me.

As far as the "locale resource", are you referring to this file: "C:\Users\Tony\Documents\Visual Studio 2017\Projects\Lakeside390\Presentation\Nop.Web\App_Data\Localization\defaultResources.nopres.xml".

Should I change that file?

<LocaleResource Name="Admin.Plugins">
    <Value>Plugins</Value>
  </LocaleResource>


Thanks,
Tony



Either change the value of the existing string resource in admin>configuration>languages>string resources, or use a different one by replacing the relevant key in sitemap.config.  That's two solutions!

This link contains good information about localization in nopCommerce: http://docs.nopcommerce.com/display/en/Localization

Hope you see how that helps!
6 years ago
Adam,

Is it possible to change it programmatically so that it is only effective for my plugin?

Thanks,
Tony
6 years ago
Carneno wrote:
Adam,

Is it possible to change it programmatically so that it is only effective for my plugin?

Thanks,
Tony



In your ManageSiteMap method, maybe something like:

var node = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Third party plugins");
node.Title = "My New Node Title";
6 years ago
Thanks Adam.

I'm sorry I do not have the expertise to figure that out.

Thanks for all of the help that you have provided.

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