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"
,
ResourceClassId =
typeof
(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.