plugin admin area path

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
I am developing plugin and have some admin controllers that should be at /Admin/ area,
How is it possible?

I have tried to add this to roat mapping

routes.MapRoute("Plugin.ReminderTemplateController.List",
                "Admin/Plugins/ReminderTemplate/List",
                new { controller = "ReminderTemplateController", action = "List", id = UrlParameter.Optional },
                new[] { "Nop.Plugin.Widgets.BasketReminder.Controllers" }).DataTokens.Add("area", "Admin"); ;


but Admin/Plugins/ReminderTemplate/List still go 404
and only
ReminderTemplate/List works fine.
7 years ago
if your plugin needs to have an admin UI, you need to implement IAdminMenuPlugin in your plugin and register a new SiteMapNode in the admin sitemap. this is detailed in the developer documentation.
7 years ago
I have already done it.

But all I need now is correct path of my plugin admin methods
which started from /admin/... path
7 years ago
Try this way:

var route = routes.MapRoute("Plugin.ReminderTemplateController.List",
  "Admin/Plugins/ReminderTemplate/List",
  new {controller = "ReminderTemplateController", action = "List", , id = UrlParameter.Optional, area = "Admin"},
  new[] {"Nop.Plugin.Widgets.BasketReminder.Controllers"}
);
route.DataTokens.Add("area", "admin");
routes.Remove(route);
routes.Insert(0, route);
7 years ago
have tried in this case no nop 404 error
just generic HTTP 404.0 IIS error
7 years ago
juliy.cesar wrote:
I am developing plugin and have some admin controllers that should be at /Admin/ area,
How is it possible?

I have tried to add this to roat mapping

routes.MapRoute("Plugin.ReminderTemplateController.List",
                "Admin/Plugins/ReminderTemplate/List",
                new { controller = "ReminderTemplateController", action = "List", id = UrlParameter.Optional },
                new[] { "Nop.Plugin.Widgets.BasketReminder.Controllers" }).DataTokens.Add("area", "Admin"); ;


but Admin/Plugins/ReminderTemplate/List still go 404
and only
ReminderTemplate/List works fine.

Try using 5 parts in the URL instead of 4, so something like this:

routes.MapRoute("Plugin.ReminderTemplateController.List",
                "Admin/Plugins/Reminder/ReminderTemplate/List",
                new { controller = "ReminderTemplateController", action = "List", id = UrlParameter.Optional },
                new[] { "Nop.Plugin.Widgets.BasketReminder.Controllers" }).DataTokens.Add("area", "Admin"); ;

I can't remember where I read it but I seem to recall that the admin area has an issue with 4 part urls. Presumably some sort of conflict with the existing routing but I'm a bit sketchy about the details.
7 years ago
4 parts route isn't a problem. It could be rather error in mapping parameters. I've specified two commas:
action = "List", , id = UrlParameter.Optional
7 years ago
I'm generally using this code to override admin area route.

        
var route = routes.MapRoute("Plugin.GroupName.PluginName.CustomVendor",
                                     "Admin/Vendor/List",
                                      new { controller = "CustomAdminController", action = "CustomVendor", orderIds = UrlParameter.Optional, area = "Admin" },
                                      new[] { "Nop.Plugin.GroupName.PluginName.Controllers" });
        route.DataTokens.Add("area", "admin");
        routes.Remove(route);
        routes.Insert(0, route);  
7 years ago
My answer on Stack Overflow: http://stackoverflow.com/a/41582072/4753489[/quote]
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.