Extend the built-in widgets
Overview
Sitefinity ASP.NET Core Renderer comes with a set of built-in widgets, such as Navigation, Content list, and Content block. You can extend these widgets to suit your requirements in the following ways:
- Customize the views of the widgets
- Modify the logic behind the widgets
- Add fields to the widget designer
Source code of built-in widgets
When you want to extend a built-in widget, you may need its source code.
Sitefinity provides the source code of all built-in widgets, including all forms widgets in Sitefinity's GutHub repository » ASP.NET Core widgets.
Customize the views for the widgets
You can add new or override the existing widget views.
You can do this by placing the file in the directory of your root web application using the following convention:
/Views/Shared/Components/{WIDGET_NAME}/{VIEW_NAME}.cshtml
Where:
WIDGET_NAME
is the name of the widget where the view will be added or overridden.
For example, SitefinityContentBlock
, SitefinityNavigation
, or SitefinityContentList
.
VIEW_NAME
is the name of the view you want to add or override.
NOTE: You can customize the widget templates for widgets that refer their own scripts, such as the Search box widget. In this case, you need to add the following using statements to the template:
Modify the logic behind the widgets
You can modify the default or add custom logic to the behavior of a built-in widget by replacing a class in the .NET DI Container.
This is the Model
class that all ASP.NET Core widgets have – for example, IContentBlockModel
, IContentListModel
, or ISectionModel
.
You can see all registered Model
classes in the WidgetCollectionExtensions.cs class.
Add fields to the widget designers
You can include additional fields in the widget designer.
You do this by extending the default Entity
class that serves as the metadata source for the automatic generation of widgets.
For more information, see Sample: Extend the Content block widget.