I'm having a problem with admin plugin routing. I already read yesterday's post, and I can't get it to work.
The difference here is that I'm developing a plugin that is both a Widget and a IAdminPlugin. The reason is that I love the new Cms features for the ease of placing widgets in the page, while at the same time the widget is powerful enough to provide a separate admin configuration zone.
The routes for the widget are OK and easy.
The problem is with the IAdminPlugin.BuildMenuItem and how to define the routes added in the RouteProvider class.
Here's my route provider code:
routes.MapRoute("Plugin.Widgets.SlideShow.Configure",
"Plugins/SlideShow/Configure/{widgetId}",
new { controller = "SlideShow", action = "Configure" },
new[] { "CallCentrix.Plugin.Widget.SlideShow.Controllers" }
);
routes.MapRoute("Plugin.Widgets.SlideShow.Display",
"Plugins/SlideShow/Display/{widgetId}",
new { controller = "SlideShow", action = "Display" },
new[] { "CallCentrix.Plugin.Widget.SlideShow.Controllers" }
);
routes.MapRoute("Plugin.Widgets.SlideShow.Track",
"Plugins/SlideShow/Track/{slideId}",
new { controller = "SlideShow", action = "Track" },
new[] { "CallCentrix.Plugin.Widget.SlideShow.Controllers" }
);
//AdminPlugin routes
routes.MapRoute("Admin.Plugin.Widgets.SlideShow.List",
"Admin/Plugins/SlideShow/SlideShow/List",
new { controller = "SlideShow", action = "List" },
new[] { "CallCentrix.Plugin.Widget.SlideShow.Controllers" }
).DataTokens.Add("area", "admin");
routes.MapRoute("Admin.Plugin.Widgets.SlideShow.TrackingReport",
"Admin/Plugins/SlideShow/SlideShow/TrackingReport",
new { controller = "SlideShow", action = "TrackingReport" },
new[] { "CallCentrix.Plugin.Widget.SlideShow.Controllers" }
).DataTokens.Add("area", "admin");
As you can see the first three routes are used for the widget configuration and display. They work OK.
For the last one, I followed the advices I found in the related forum topics of using a 5 part route and adding the "area" DataToken.
Here's is the menu building function:
public void BuildMenuItem(Telerik.Web.Mvc.UI.MenuItemBuilder menuItemBuilder)
{
menuItemBuilder.Text("SlideShow").Items(y =>
{
y.Add()
.Text("Manage SlideShows")
.Url("Admin/Plugins/SlideShow/SlideShow/List");
y.Add()
.Text("Tracking Report")
.Url("Admin/Plugins/SlideShow/SlideShow/TrackingReport");
});
}
I'm using the Url action and specifying the exact same Url I configured earlier.
When I open the Admin area, I can see the Plugins > SlideShow menu, and the two items 'Manage SlideShows' and 'TrackingReport'. The funny thing is that the Urls are automatically converted into:
http://localhost:3810/Admin/Widget/Admin/Plugins/SlideShow/SlideShow/List
and:
http://localhost:3810/Admin/Widget/Admin/Plugins/SlideShow/SlideShow/TrackingReport
As you can see, the framework is adding a 'Admin/Widget' part to the URL. I've been scanning the source to try to find where and why this is done, but can't find it.
Of course, being 'widget' one the added parts I guess this is related to the Plugin implementing IWidget. Here's the class signatura in case it helps:
public class SlideShowPlugin: BasePlugin, IWidgetPlugin, IAdminMenuPlugin, IConsumer<EntityInserted<Slide>>, IConsumer<EntityUpdated<Slide>>, IConsumer<EntityDeleted<Slide>>
Any hints, ideas or perhaps sample code of a similar project would be appreciated.
Thanks!