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:
Create a new Sitefinity CMS page.
- Drag and drop a Blogs posts widget on you page.
- Open the Edit mode of the widget and click on Single Item Settings.
- 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.
- 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:
NOTE: For more information about adding fields to widget templates, see Add new fields to widget templates.
- Click Save changes.
- 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.