logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
sweeperqb  
#1 Posted : Wednesday, June 15, 2022 4:40:36 PM(UTC)
sweeperqb

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 5/30/2020(UTC)
Posts: 125

Thanks: 14 times
Was thanked: 3 time(s) in 3 post(s)
I registered two new routes in my Plugin using the following code:

Code:
public void RegisterRoutes(RouteCollection routes)
        {
            if (routes["Plugins_General_InventoryPlugin_Admin"] == null)
            {
                var route = routes.MapRoute(
                    name: "Plugins_General_InventoryPlugin_Admin",
                    url: "Admin/InventoryPlugin/{controller}/{action}/{id}",
                    defaults: new { controller = "InventoryAdmin", action = "Config", id = UrlParameter.Optional },
                    namespaces: new[] { "InventoryPlugin.Areas.Admin.Controllers" }
                );
                route.DataTokens["area"] = "Admin";
            }

            if (routes["Plugins_General_InventoryPlugin_Retail"] == null)
            {
                var route = routes.MapRoute(
                    name: "Plugins_General_InventoryPlugin_Retail",
                    url: "InventoryPlugin/{controller}/{action}/{id}",
                    defaults: new { controller = "InventoryRetail", action = "Index", id = UrlParameter.Optional },
                    namespaces: new[] { "InventoryPlugin.Controllers" }
                );
            }
        }


The first route works correctly and shows my plugin configuration page. The second route causes the following error at the top and bottom of the website in place of the Header and Footer:

Quote:
Multiple types were found that match the controller named 'Category'. This can happen if the route that services this request ('InventoryPlugin/{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter. The request for 'Category' has found the following matching controllers: AbleCommerce.Controllers.CategoryController AbleCommerce.Areas.Admin.Controllers.CategoryController


If you look at my route registration, you can clearly see I've specified controller namespaces for each of the routes. I also went through the AbleCommerce_WAP routes and added namespaces for all of those, but it didn't make a difference. The only way I could get rid of the error was to replace the {controller}/ part of the URL with the physical controller name. But then I have to do that for every new controller. Any other ideas?

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

shaharyar  
#2 Posted : Monday, June 20, 2022 4:19:55 AM(UTC)
shaharyar

Rank: Advanced Member

Groups: Admin, Developers, Registered, HelpDesk, Authorized User
Joined: 10/5/2018(UTC)
Posts: 703

Thanks: 5 times
Was thanked: 113 time(s) in 112 post(s)
For the retail side, you should always make use of the widgets. You can register an action method as a widget in your plugin controller and then view the content by dragging and dropping the widget on the content page.

You can create a content page from the admin website menu, set the inner and outer template, and then drag and drop the widget.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.