Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Delete 61 posts 449 karma points
    Sep 26, 2017 @ 09:59
    Delete
    0

    Documentation

    How to use uTaxonomy:

    1. Install package
    2. In Developer -> Data Types section create new data type. (for example, "Gender")enter image description here
    3. Add a new data type to a Document type.enter image description here
    4. 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.enter image description here

    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))
    
  • Paul 142 posts 488 karma points
    Apr 05, 2019 @ 11:12
    Paul
    0

    Don't forget to stick the following on your view pages to prevent the context not found error.

    @using Delete.uTaxonomy.Services;
    @using Delete.uTaxonomy.Models;
    
Please Sign in or register to post replies

Write your reply to:

Draft