Admin Plugin Route Problem

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

I have a problem with a admin plugin that i'm developing.
This is the scenario:

My plugin name is: Nop.Plugin.Misc.PrenotazioneServizi

My route provider for plugin is:

            routes.MapRoute("Nop.Plugin.Misc.PrenotazioneServizi.Servizi",
                "PrenotazioneServizi/Servizio/{action}/{id}",
                new { controller = "Servizio", action = "List", id = UrlParameter.Optional },
                new[] { "Nop.Plugin.Misc.PrenotazioneServizi.Controllers" }
            ).DataTokens.Add("area", "admin");

My menu item route is:

        public virtual void BuildMenuItem(MenuItemBuilder menuItemBuilder)
        {
            menuItemBuilder.Text("Gestione Servizi").Items(y =>
            {
                y.Add()
                    .Text("Servizi")
                    .Url("/PrenotazioneServizi/Servizio/List");
                y.Add()
                    .Text("Risorse")
                    .Url("/PrenotazioneServizi/Risorsa/List");
                y.Add()
                    .Text("Prenotazioni")
                    .Url("/PrenotazioneServizi/Prenotazione/List");
            });
        }

Inside plugin there are two different controllers for the moment:

       Controllers/RisorsaController.cs
       Controllers/ServizioController.cs

When i click on link menu "Servizi" in my plugin menu all works fine end I can view the list of record "Servizi".
At this point starts my problems because all action inside this view are rendered with the following urls:

     localhost/admin/Servizio/Create
     localhost/admin/Servizio/Edit/3

while the correct urls are:

     localhost/PrenotazioneServizi/Servizio/Create
     localhost/PrenotazioneServizi/Servizio/Edit/3

If remove the dataTokens Area,Admin all works fine inside my views but the url menu of admin area are displayed without admin suffix.

I have already tried the 5 parts urls but i cannot resolve the problem.

How can I Fix?

Thanks all for help.
11 years ago
koreano wrote:
Hi All,

I have a problem with a admin plugin that i'm developing.
This is the scenario:

My plugin name is: Nop.Plugin.Misc.PrenotazioneServizi

My route provider for plugin is:

            routes.MapRoute("Nop.Plugin.Misc.PrenotazioneServizi.Servizi",
                "PrenotazioneServizi/Servizio/{action}/{id}",
                new { controller = "Servizio", action = "List", id = UrlParameter.Optional },
                new[] { "Nop.Plugin.Misc.PrenotazioneServizi.Controllers" }
            ).DataTokens.Add("area", "admin");

My menu item route is:

        public virtual void BuildMenuItem(MenuItemBuilder menuItemBuilder)
        {
            menuItemBuilder.Text("Gestione Servizi").Items(y =>
            {
                y.Add()
                    .Text("Servizi")
                    .Url("/PrenotazioneServizi/Servizio/List");
                y.Add()
                    .Text("Risorse")
                    .Url("/PrenotazioneServizi/Risorsa/List");
                y.Add()
                    .Text("Prenotazioni")
                    .Url("/PrenotazioneServizi/Prenotazione/List");
            });
        }

Inside plugin there are two different controllers for the moment:

       Controllers/RisorsaController.cs
       Controllers/ServizioController.cs

When i click on link menu "Servizi" in my plugin menu all works fine end I can view the list of record "Servizi".
At this point starts my problems because all action inside this view are rendered with the following urls:

     localhost/admin/Servizio/Create
     localhost/admin/Servizio/Edit/3

while the correct urls are:

     localhost/PrenotazioneServizi/Servizio/Create
     localhost/PrenotazioneServizi/Servizio/Edit/3

If remove the dataTokens Area,Admin all works fine inside my views but the url menu of admin area are displayed without admin suffix.

I have already tried the 5 parts urls but i cannot resolve the problem.

How can I Fix?

Thanks all for help.


https://www.nopcommerce.com/boards/t/20478/broken-menus-in-admin-area-whilst-trying-to-make-a-plugin-admin-page.aspx

Can you try this and see if it works? :D
11 years ago
Hi woon the route now works fine but I don't understand how can hide the close notification icon.

Can you help me?

Thanks a lot.
11 years ago
koreano wrote:
Hi woon the route now works fine but I don't understand how can hide the close notification icon.

Can you help me?

Thanks a lot.


You can just find out the class for the bar (use your browser's developer tool to help you) and set the display to none in css. :D
11 years ago
I found the class bar-notification but i'm not be able to reach it inside css files.
Do you know where is it?
11 years ago
koreano wrote:
I found the class bar-notification but i'm not be able to reach it inside css files.
Do you know where is it?


If I remember wrongly it's not inside the CSS. Just add a new style will do. :D
11 years ago
OK! Now all works fine but I have last little issue.

By adding line to menu.cshml all works fine but when I click for example Customer, all admin menu item that has a submenu item, link to last visited view, in this case Customer/List.

Only the plugins extra menu works fine.

Do you know why?

Thanks.
11 years ago
koreano wrote:
OK! Now all works fine but I have last little issue.

By adding line to menu.cshml all works fine but when I click for example Customer, all admin menu item that has a submenu item, link to last visited view, in this case Customer/List.

Only the plugins extra menu works fine.

Do you know why?

Thanks.


I don't get the question. Can you try to explain further? :D
11 years ago
Ok

I have added this line to menu.cshtml to solve the routing problem:

item.RouteValues = new RouteValueDictionary() { { "area", "Admin" } };

All works fine but there is a little problem explained below:

When user click on

http://localhost/Admin/Customer/List

all menu item that has subitems for example News, Blog, etc.. has a link to http://localhost/Admin/Customer/List.

Do you understand the problem now?
11 years ago
koreano wrote:
Ok

I have added this line to menu.cshtml to solve the routing problem:

item.RouteValues = new RouteValueDictionary() { { "area", "Admin" } };

All works fine but there is a little problem explained below:

When user click on

http://localhost/Admin/Customer/List

all menu item that has subitems for example News, Blog, etc.. has a link to http://localhost/Admin/Customer/List.

Do you understand the problem now?


Ok. So when users are at http://localhost/Admin/Customer/List, all the links (for example Blog -> Blog Post) points to http://localhost/Admin/Customer/List instead of the correct link?

I am trying to reproduce this error, what version are you in? :D
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.