Binding custom fields to certain Content items
Hi,
I have a widget that creates classifications if they do not already exist.
I'd like to know how to programmatically bind these classifications to Document & Files, so they appear there (when creating and editing elements), in the same way they do when doing it manually in the backend, through Content > Document & Files > Custom Fields.
Thanks.
Hi Thomas,
In edit and new screen of an item we use ContentViewSectionElement and inject HierarchicalTaxonFieldDefinitionElement
example
public
static
HierarchicalTaxonFieldDefinitionElement CategoriesFieldWriteMode(ConfigElement section)
return
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
;