Thank you for using our services.
Here's how to create a sub-category category widget:
1. First we add a class file to our Sitefinity project and name it CustomTaxonomyControl. Our class inherits from TaxonomyControl. The TaxonomyControl has several modes in which it renders taxonomies - HorizontalList, VerticalList and Cloud. Each one of the options is represented by a Repeater on the front-end. We override InitializeControls method of TaxonomyControl and subscribe to the TaxaRepeater ItemDataBound event. TaxaRepeater is the repeater, which renders our taxonomies. Then we can the base implementation of InitializeControls:
.TaxaRepeater.ItemDataBound += TaxaRepeater_ItemDataBound123;
In our custom control we have three properties - ParentCategory, FieldName and ParentCategory. The first two come from TaxonomyControl and we hardcode their values, so that the field name will always be Category (Tags do not have hierarchical structure), and the taxonomyId will be set to the Categories taxonomy id. We do that in case we're going to use the control to display categories only. If you want to use it for other hierarchical taxonomies, you don't need to fill these properties. You will be able to fill them though the Advanced properties of the widget (in the UI) and set the fieldName to your hierarchical taxonomy's fieldName, as well as the TaxonomyId to its corresponding id. The ParentCategory property from type string is added by us, and we'll use it to specify the parent (root category). By doing this, your widget will only display categories (hierarchical taxonomies, which are children of this taxonomy).
In the ItemDataBound event of the Repeater control we call the base ItemDataBound and then we check the url of each taxonomy, bound to the Repeater. If the url doesn't contain our parentCategory, followed by forward slash (this way we make sure that this will catch the parent taxonomy, as well), we set Visible = false for these items.
sender, RepeaterItemEventArgs e)
(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
var taxonData = e.Item.DataItem
var link = e.Item.FindControl(
&& !taxonData.Url.Contains(ParentCategory.Trim().ToLower() +
You can register the control as a custom control in Sitefinity and use it.
The whole code is attached to the ticket.
All the best,
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking
system and vote to affect the priority of the items