Register new widgets in Sitefinity CMS toolbox
After you implement new widgets, you must register them in the Sitefinity CMS toolbox. You do this by decorating the widget controller class with the ControllerToolboxItem attribute. This attribute defines the following properties of the widget:
|The unique developer name of the widget, for example, ContentBlock_MVC
|The display name of the widget, visible in the widget toolbox, for example, Content block.
The unique developer name of the toolbox section, in which you add the widget. This can be an existing section name. To find out the names of existing sections, go to the ~/Sitefinity/Administration/Settings/Advanced/Toolboxes folder and expand the PageControls » Sections nodes. For example, you can add your new widget to the ContentToolboxSection, defined as the constant ToolboxesConfig.ContentToolboxSectionName.
You can also create a new section and Sitefinity CMS will automatically create toolbox section with the name you have specified.
|The unique name of a Sitefinity module that has to be explicitly activated, so that you can see the widget in the toolbox. You can see the names of modules by navigating to the ~/Sitefinity/Administration/Settings/Advanced/System folder and expanding ApplicationModules.
|The unique developer name of the toolbox, in which you register the widget. By default, this will be the page controls toolbox PageControls (the constant ToolboxesConfig.PageControlsToolboxName). You can also specify another name. For example, when developing MVC form fields, you use FormControls or the constant FormsConstants.FormControlsToolboxName.
IMPORTANT: Required when developing MVC form fields.
|This property enables you to control the styles of the toolbox item. The widget controller must implement either the ICustomWidgetVisualization interface or the ICustomWidgetVisualizationExtended interface. These interfaces enable you to use special styles in the toolbox and when dropping an empty widget on a page.
For more information about new widgets, see Create widgets.
For an example of how to implement a Content Block widget controller, take a look at the GitHub repository.
Sitefinity CMS automatically detects all widget controllers that are decorated with the ControllerToolboxItem attribute and adds the corresponding item to the widget toolbox.
The following sample demonstrates how to decorate the widget controller with the ControllerToolboxItem attribute: