Create and edit widget templates

Create a new widget template

  1. Go to Sitefinity’s backend (http://<yoursite>/sitefinity)
  2. In the main menu, click Design » Widget Templates.
  3. Click Create a template.
  4. In the This template is applied to... dropdown box, select the widget for which you want to create a template
    For example if you want to create new template for the single post item view of the blogs, select Blogs postssingle.
  5. In the text area, write your code for the template.
  6. To insert a property field of the widget, in the template, click the desired field in the right menu.
    A window displaying the syntax of the field appears.

    NOTE: All custom fields you have created for the content type you have chosen in This template is applied to..., appear under Other data node.

  7. To add the sample code, in the text area, click Insert.
  8. When you have entered the code, in Template name field, enter name of your template.
  9. Optionally, identify a widget template using the NameForDevelopers property.

    NOTE: You use the property to identify a widget template using a readable name instead of a GUID. This field is not required and some of the widget templates do not have a value for NameForDevelopers by default. If necessary, you can assign a value for the property.
    Sitefinity CMS does not guarantee the uniqueness of the NameForDevelopers property for each application.
    In addition, there is a new virtual path to each named widget template: ~/SfCtrlPresentation/ByName/[NameForDevelopers].ascx. You can put this virtual path in LayoutTemplatePath input field of any widget to make it render the selected template.

  10. To save your work, click Create this template.
    EXAMPLE: For your widget template to work properly, you need some specific declarations. For example, the Document Single template must have the following declarations:

    To find the correct declarations for your template you can go and edit some of the templates that are coming with Sitefinity CMS.

Edit an existing widget template

  1. In the main menu, click Design » Widget Templates.
  2. In the text area, write your code for the template.
  3. To insert a property field of the widget, click the desired field in the right menu.
    A window displaying the syntax of the field appears.<

    NOTE: All custom fields you have created for the content type you have chosen in This template is applied to..., appear under Other data node.

  4. To add the sample code, click Insert.
  5. When you are finished, click Save changes.

Was this article helpful?