Binding custom fields to certain Content items

Posted by Community Admin on 04-Aug-2018 10:01

Binding custom fields to certain Content items

All Replies

Posted by Community Admin on 08-Jun-2011 00:00
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.
Posted by Community Admin on 10-Jun-2011 00:00
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
        
    ;

As for the custom fields

- you can add them through custom fields dialog ( check attached screenshot cf1)
- default fields can't be deleted or edited. There is a service that checks default and custom fields and there are separately bound. As you can see even categories and tags are put the in the custom fields section. So you have to add your custom control through the UI dialog.

Kind regards,
Ivan Dimitrov
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
This thread is closed