Customize the markup of all widgets of specific type

Sitefinity CMS enables you to customize the templates of a specific widget type, so that you can apply the template to any widget of this type that you add to your website. You do this in the widget designer, that is, in Edit mode of the widget type.

This article demonstrates how to modify the template applied to all Blog posts widgets by adding a footer text consisting of all tags used in a blog post. You do this by editing the widget type markup.

PREREQUISITES: You have created content of type Blogs.
For more information, see Blogs and blog posts.

You now need to customize the template markup via the widget designer:

  1. Create a new Sitefinity CMS page.
  2. Drag and drop a Blogs posts widget on you page.
  3. Open the Edit mode of the widget and click on Single Item Settings.
  4. From the Detail Templates dropdown menu, select Full blog post item and click on the Edit selected template button.
    In the widget template, the markup looks a lot like a standard ASP.NET UserControl. The reason is that in all cases, when bound to a widget, widget templates are loaded internally by Sitefinity CMS as ASP.NET UserControls. Therefore, you can modify widget template markup the same you would modify an ASP.NET UserControl markup.
  5. Under the Common data list on the right side of the  screen, select Tags.
    Insert a new FlatTaxonField field, as shown in the code below:
  6. NOTE: For more information about adding fields to widget templates, see Add new fields to widget templates.

  7. Click Save changes.
  8. Save the widget and publish the page.

To test the new widget, simply open the page on the frontend and click on the blog post title to see the full content. You should see all tags in the footer of all blog posts in all Blog posts widgets.

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?