mholyfield wrote:I want to create a plugin and be able to navigate directly to the plugin view. Is this possible, or is there a way to place a plugin on a single page? I've worked through the examples to create a widget plugin, but my new widget plugin appears on every page.
Thank you.
You can definitely do this, it can be done on any type of plugin, not only Widget plugin:
1. Create a new View and Action (and Model if needed), like how you would do in a normal MVC application.
2. Make the View an Embedded Resource, and when returning the View from your controller, use the following rule:
return View("Nop.Plugin.Widget.YourPlugin.Views.ViewName", model);
Not that since we've marked the View as an embedded resource, we have to specify the fully-qualified name of the View, as if the View is now a class. So the general rule is:
{Plugin_Default_Namespace}.{View_Folder_Name}.{View_Name_Without_CSHTML}
3. Edit (or add) RouteProvider.cs in your plugin to point to your Action, for example:
routes.MapRoute("ROUTE_NAME",
"ROUTE_URL",
new { controller = "YOUR_CONTROLLER", action = "YOUR_ACTION" },
new[] { "YOUR PLUGIN DEFAULT NAMESPACE" }
);
For this, open the RouteProvder.cs in any other plugins and you'll have a better clue.
4. If everything wires up correctly, you'll be able to visit your link through ROUTE_URL, or by specifying in code:
Url.RouteUrl("ROUTE_NAME")
:)