IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
HierarchicalTaxonField is used when you want to associate a content item with a hierarchical taxon (i.e. category). Built-in content items have Category and Tags fields available, but you can also create custom fields for all modules, which are of type "classification". With all those, you can use HierarchicalTaxonField:
Taxonomies and taxa are associated with content items through the creation of custom fields, no matter if you're developing a static module or a dynamic one. The difference is in the way you create the definition. With a static module, you need to do it with the following code:
var categorySelectorField =
new
HierarchicalTaxonFieldDefinitionElement(section)
{
ID =
"categoriesFieldControl"
,
DataFieldName =
"Category"
DisplayMode = FieldDisplayMode.Write,
ResourceClassId =
typeof
(TaxonomyResources).Name,
TaxonomyId = TaxonomyManager.CategoriesTaxonomyId,
WebServiceUrl =
"~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc"
AllowMultipleSelection =
true
WrapperTag = HtmlTextWriterTag.Li,
Title =
"Categories"
ExpandableDefinitionConfig =
Expanded =
false
ExpandText =
"ClickToAddCategories"
(TaxonomyResources).Name
}
};
taxonSection.Fields.Add(categorySelectorField);
When you are creating a custom field of type "classification", the choices for a widget to select classification items is available as a dropdown list. If you choose "Tree-like selector", you are in fact choosing HierarchicalTaxonField. You don't need to specify a custom type. You can also choose the taxonomy to work with.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important