Concepts > Widgets

Widgets are small, mostly self-contained units of functionality that can be placed on a MrCMS pages.

Widget is the abstract base class that can be extended to place additional properties that contain the data required. These properties (as with all SystemEntity descendants in MrCMS) are attempted to be automapped by FluentNHibernate's automapper and can be configured explicitly by implementing IAutoMappingOverride<T> (again from FluentNHibernate).

Widgets typically come in one of 2 flavours:
  • An entity that contains the data to show
  • An entity that can be configured to show data from elsewhere
When rendering these to the page, you create a WidgetClassName.cshtml (e.g. TextWidget.cshtml for MrCMS.Web.Apps.Core.Widgets.TextWidget) in the /Views/Widgets folder of your App.

In the case of the first flavour there, your model will just be the type of the widget.

In the case of the second, you will need to implement GetWidgetModelBase<T> for your widget type. This is an abstract class with a single method to implement: object GetModel(T widget); . Your implementation will be auto-wired upto the IoC by MrCMS's internals, so you can constructor-inject any required dependencies.

Last edited Nov 14, 2014 at 3:54 PM by gmstr, version 1


No comments yet.