I can't call Widget for a new Admin Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 лет назад
I Create a New plugin to manage back Office menus,

I implement the interface IWidgetPlugin to create a new widget zone :

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

And I had called this widget zone from one view "_AdminLayout.csHtml" under Nop.Admin project with the extended helper @Html.Widget

@Html.Widget("ebm_MenuManager_BackOffice")


how can i display my widget zone in this back office view with the widget call ?
8 лет назад
Hi Omar,

I would say that you almost got it. You should be implementing a method like:

public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName, out RouteValueDictionary routeValues)

This method is specified in IWidgetPlugin too. As you can see parameters have the reserved 'out' keyword, so it would be something similar to:

public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName, out RouteValueDictionary routeValues)
        {
            actionName = "MyAction";
            controllerName = "MyController";
            routeValues = new RouteValueDictionary
            {
                {"Namespaces", "My.Space.Name.To.Controllers"},
                {"area", null}
            };
        }


In MyController.MyAction you should be returning a view.

Greetings,
8 лет назад
Hi Thanks Jacob for this fast reply,

I also implemented the three method of IWidgetPlugin just like this :

 public void GetConfigurationRoute(out string actionName, out string controllerName, out System.Web.Routing.RouteValueDictionary routeValues)
        {
            actionName = "ConfigureMenus";
            controllerName = "Menu";
            routeValues = new RouteValueDictionary(){
                { "Namespaces", "Ebm.Plugin.Widget.Menu.Controller" },
                { "area", null }
            };
        }

        public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName, out System.Web.Routing.RouteValueDictionary routeValues)
        {
            actionName = "GetMenuById";
            controllerName = "Menu";
            routeValues = new RouteValueDictionary(){
                { "Namespaces", "Ebm.Plugin.Widget.Menu.Controller" },
                { "area", null },
                { "widgetZone", widgetZone}
            };
        }

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


And the route is okay and i can display the widget with this call :
@Html.Action("ActionName", "ControllerName", new {RouteValues})
, And the matter that i want to do this call with @Html.Widget but the problem that this new widget zone wasn't described to the admin widget zone and for have an idea i look into the WidgetController and i saw that the following action WidgetByZone its not the same for the action in the Nop.Web's WidgetController ,

Any idea please about this ?


Best Regards.
8 лет назад
As far as I'm able to see, it seems that you're going in the right direction. That being said, I'm not really sure if I understand the last part of your post. Anyway, I have just realized that you are trying to render the widget in the admin panel. I must admit that never implemented one for there.

Have you checked if your widget is active in ContentManagement > Widgets?. There is an "Is active" column that allows plugins to be rendered.

Greetings,
8 лет назад
Thank you Jacob , the problem is solved when I did Is Active in ContentManagement > Widgets .


Best Regards and thanks again for your precious information.
8 лет назад
Awesome!

Happy to help! ^^
6 лет назад
Jacob84 wrote:
As far as I'm able to see, it seems that you're going in the right direction. That being said, I'm not really sure if I understand the last part of your post. Anyway, I have just realized that you are trying to render the widget in the admin panel. I must admit that never implemented one for there.

Have you checked if your widget is active in ContentManagement > Widgets?. There is an "Is active" column that allows plugins to be rendered.

Greetings,



Thanks helped , As of Version 3.80 its in Configuration => Widgets
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.