The following tutorial demonstrates how to make the template of a custom widget to be editable through the UI.
SimpleView
Perform the following:
InitializeControls
LayoutTemplateName
.ascx
ControlTemplateInfo
resourceClassId
controlDisplayName
areaName
TemplateKey
NOTE: You must use an instance of the PageManager class to operate with widget templates. In the code sample below, a specific widget template is retrieved with specific Name, AreaName, DataType, and ControlType.
PageManager
Name
AreaName
DataType
ControlType
Use the following code sample:
EditableWidgets
To register and use the custom resource class in Global.asax, register the class by subscribing to SystemManager.ApplicationStart method in the ApplicationStart event. The registered custom resource class can be further extended with additional resource entries from Administration » Interface Labels and Messages.
SystemManager.ApplicationStart
Register the widget template for the control using the resource class entries. All editable templates are stored in the Sitefinity CMS database. If you edit the templates through the UI, those edits are kept in the database and the template is served from there when the widget is instantiated. If there are no edits, Sitefinity CMS returns the embedded resource. Keeping the templates in the database also gives the possibility to reset them to the default ones. You can always go back one version in the embedded resource, if someone has made the template unusable from the UI.
To create such a database record for your template, you can use the Sitefinity CMS API. You can do this only once in the lifetime of your project in the SystemManager.ApplicationStart method:
The code above creates a new entry in the database with the information you give for your template. That information includes the namespace of your ascx embedded resource, type of the widget, name for the template to display in the UI, the assembly it resides in, etc. From now on your template will be retrieved from the database and will appear in the backend list.
You can also manage templates through the custom control designer. For more information, see Manage custom control templates through the designer.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
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.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important