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

NOTE: The source code of the built-in widget is located in the ASP.NET Core widgets GitHub repository.

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.

GITHUB EXAMPLE: To view a sample of how to extend the Content block widget and its Model and the Entity classes, see Extend the Content block widget sample on Sitefinity GitHub repository.

Extend the Content list widget

For more information, see Extend and customize the Content list widget.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?