This document is a guide for developers to the Widget Plugin of GrandNode.
Widget Plugins inherit, not surprisingly, from BasePlugin, and from IWidgetPlugin
IWidgetPlugin adds 3 Method declarations, but only 2 last of them are unique for Widgets
GetDisplayWidgetRoute() makes it possible to call Action which will return our PartialView
GetWidgetZones() is important method that returns List<string> with names of all locations where Plugin’s View should be displayed (usually only one zone).
Below is example existing in GoogleAnalyticsPlugin
For example, we want to display some Widget in main shop page.
Let’s start from Index.cshtml.
The Index.cshtml calls HtmlExtensions.Widget() (Html Helper Action), the value of widgetZone parameter is “home_page_top”
HtmlExtensions.Widget() calls WidgetController.WidgetsByZone(). The argument remains the same.
This Action, however, returns not directly a PartialView, but the List<RenderWidgetModel> that makes it possibly to identify what PartialView actually to return.
Finally, our Plugin’s Action PublicInfo is called, and we can return anything we request for.
But it is of course possible to return View() with ViewModel.
Assuming you’re mainly interested in admin widgets, you can add your content in these widget zones