Extend the built-in widgets

Overview

Sitefinity .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 .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.

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 .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

GITHUB EXAMPLE: You can find examples on how to extend the Model, ViewModel, View, and the Entity classes as part of the Quantum demo sample in Sitefinity GitHub repository:

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?