In Developer -> Data Types section create new data type. (for
example, "Gender")
Add a new data type to a Document type.
Now you can use the new data type for fields in your document types.
Fields will have dropdown select with ability to select multiple
items.
Models
Taxonomy model classes: Taxonomy and TaxonomyItem.
TaxonomyService
TaxonomyService contains 4 methods to retrieve taxonomy list or specific item from Umbraco.
GetTaxonomyTree(string dataTypeName)
Returns taxonomy model for specified data type name.
Example:
var items = TaxonomyService.GetTaxonomyTree("Gender");
FlattenList(string dataTypeName)
Returns taxonomy items as a flat list.
Example:
var items = TaxonomyService.FlattenList("Gender");
GetTaxonomyById(string dataTypeName, Guid id)
GetTaxonomyById(string dataTypeName, string id)
Returns concrete taxonomy item by id. Use data type name and item id (Guid) as parameters.
Example:
var item = TaxonomyService.GetTaxonomyById("Gender", "7ce50708-8aa0-40ca-acc9-1dad950803ab");
var item = TaxonomyService.GetTaxonomyById("Gender", Guid.Parse("b99411a2-f78c-4afb-a112-6d7e15a8d270"));
ToSelectListItems(this IEnumerable
Extension method that converts flat taxonomy list to IEnumerabe
Example:
var items = TaxonomyService.FlattenList("Location drop down");
@Html.DropDownList("Location", items.ToSelectListItems(true," - ", true))
Documentation
How to use uTaxonomy:
Models
Taxonomy model classes: Taxonomy and TaxonomyItem.
TaxonomyService
TaxonomyService contains 4 methods to retrieve taxonomy list or specific item from Umbraco.
GetTaxonomyTree(string dataTypeName)
Returns taxonomy model for specified data type name.
Example:
FlattenList(string dataTypeName)
Returns taxonomy items as a flat list.
Example:
GetTaxonomyById(string dataTypeName, Guid id)
GetTaxonomyById(string dataTypeName, string id)
Returns concrete taxonomy item by id. Use data type name and item id (Guid) as parameters.
Example:
ToSelectListItems(this IEnumerable
Extension method that converts flat taxonomy list to IEnumerabe
Example:
Don't forget to stick the following on your view pages to prevent the context not found error.
is working on a reply...