New Plugin

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

I'm working to create a new Plugin. However every time I click Configuration then Plugin in the admin area I get the debugger in visual studio pointing to EnsurePluginsAreLoaded(); method in PluginFinder.cs file. Also I do not see my plugin displayed in the admin area plugin list. Below is my code
Thanks for your help
RouteProvider

namespace Nop.Plugin.Widgets.Banner
{
    public partial class RouteProvider : IRouteProvider
    {
        public void RegisterRoutes(RouteCollection routes)
        {
             routes.MapRoute("Plugin.Widgets.Banner.Configure",
                 "Plugins/WidgetsBanner/Configure",
                 new { controller = "WidgetsBanner", action = "Configure" },
                 new[] { "Nop.Plugin.Widgets.Banner.Controllers" }
            );

        }
        public int Priority
        {
            get
            {
                return 0;
            }
        }
    }
}


BannerPlugin.cs




namespace Nop.Plugin.Widgets.Banner
{
    public class BannerPlugin:BasePlugin
    {
        public override void Install()
        {
            base.Install();
        }
        public override void Uninstall()
        {
            base.Uninstall();
        }
    }
}



ConfigurationModel


namespace Nop.Plugin.Widgets.Banner.Models
{
    public class ConfigurationModel
    {
         public ConfigurationModel()
        {
            
        }
        public string Id { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Banner.Name")]
        public string Name { get; set; }
    }
}



Controller

namespace Nop.Plugin.Widgets.Banner.Controllers
{
    public class WidgetsBannerController : Controller
    {
        public ActionResult Configure()
        {
            var model = new ConfigurationModel();
            model.Id = "0";
            model.Name = "Test";
            return View("Nop.Plugin.Widgets.Banner.Views.Configure",model);
        }
    }
}


11 years ago
The plugin loader needs to know what the configuration route is, so since its a widget
have your plugin implement IWidgetPlugin:


public class BannerPlugin:BasePlugin, IWidetPlugin
{
public IList<string> GetWidgetZones()
{
   return new List<string>() { "content_before", "header_menu_before" , "etc etc etc"  };
}

public void GetConfigurationRoute( out string actionName , out string controllerName , out RouteValueDictionary    routeValues )
{
   actionName = "Configure";
   controllerName = "BannerPlugin";
   routeValues = new RouteValueDictionary()
   {
      { "Namespaces" , "Nop.Plugin.Widgets.Banner.Controllers" } ,
      { "area" , null }
   };
}
}
11 years ago
Hi,

I completed that and still get the same issue.
11 years ago
abidz005 wrote:
Hi,

I completed that and still get the same issue.


Did you copy this plugin from a pre-existing project? It could be that you have not changed your output directory to a correct folder. :)
11 years ago
Hi,

Thanks for your response. No, I created this as new plugin.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.