Showing Widget On The Homepage

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
I designed a widget which works perfect in the admin panel but when it comes to showing the PublicInfo on the home page,i t doesn't show anything here what I've done for the PublicInfo part.

Plugin (inherits BasePlugin and IWidgetPlugin)

    public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName, out RouteValueDictionary routeValues)
    {
      actionName = "PublicInfo";
      controllerName = "WidgetsAhsenSlider";
      routeValues = new RouteValueDictionary()
            {
                {"Namespaces", "Nop.Plugin.Widgets.AhsenSlider.Controllers"},
                {"area", null},
                {"widgetZone", widgetZone}
            };
    }

    public IList<string> GetWidgetZones()
    {
      return new List<string>() { "home_page_slider" };
    }


RouteProvider:

public void RegisterRoutes(RouteCollection routes)
    {
      routes.MapRoute("Plugin.Widgets.AhsenSlider.PublicInfo",
            "Plugins/WidgetsAhsenSlider/PublicInfo",
            new { controller = "WidgetAhsenSlider", action = "PublicInfo" },
            new[] { "Nop.Plugin.Widgets.AhsenSlider.Controllers" }
      );

    }


Controller:

    [ChildActionOnly]
    public ActionResult PublicInfo(string widgetZone)
    {
      List<SliderModel> allModels = this.GetAllSliderModels();
      return View(PUBLIC_INFO_VIEW, allModels);
    }


View:

View is there.

Home Page:
@Html.Widget("home_page_slider")
11 years ago
I've found the solution. Instead of using Widget thingy, I said @Html.Action("PublicInfo","Controller") where I want to show my own widget and it works charmingly. Since ControllerFactory looks for the plugin everywhere in every assembly and namespaces (as long as they are referenced somewhere) then it works even if you are having them in different plugin which has different namespaces than your root.
11 years ago
It could be that you didn't enabled the widget under Content Management -> Widget. Merely installing it is not enough, you have to set it as active.
11 years ago
I did enable it but it didn't work. It should be something else but I couldn't figure out so I used the other way.
6 years ago
can you please share how did u solved this problem
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.