+1-888-365-2779
Try Now
More in this section

Forums / Project Feather / Accessing Classifications within Views

Accessing Classifications within Views

5 posts, 2 answered
  1. Stu
    Stu avatar
    3 posts
    Registered:
    08 May 2014
    14 Apr
    Link to this post

    Hi,

    Prior to Feather we would be able to access classifications applied to a module by using a Hierarchical/FlatTaxon tag built into Sitefinity to list out the associated classifications to a particular content type. Is there anything available to pull these taxonomies using Razor?

    Thanks!

    Stu

    Answered
  2. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    29 Sep 2016
    02 May
    Link to this post
    Hi Stu,

    If you refer to showing the selected taxa on the frontend, you can do this using Feather widgets, as well. It depends on the content type of the item, but the following works on dynamic content and built-in content items (news etc.):
    @*Start Tags field*@
    <div>
        <strong> Tags :</strong>
     
        @if(Model.Item.Fields.Tags!=null)
        {
        <ul @Html.InlineEditingFieldAttributes("Tags", "FlatTaxon")>
        @foreach (var taxon in Model.Item.GetFlatTaxons("Tags"))
        {
            <li>@taxon.Title.ToString()</li>  
        }
        </ul>
        }
    </div>
    @*End Tags field*@
     
    @*Start Category field*@
    <div>
        <strong> Categories :</strong>
     
        @if(Model.Item.Fields.Category!=null)
        {
        <ul @Html.InlineEditingFieldAttributes("Category", "HierarchicalTaxon")>
         @foreach (var taxon in Model.Item.GetHierarchicalTaxons("Category"))
        {
            <li>@taxon.Title.ToString()</li>  
        }
        </ul>
        }
    </div>
    @*End Category field*@

    or just:
    <div>
            Tags: @string.Join(", ", Model.Item.GetFlatTaxons("Tags").Select(t=> t.Title))
        </div>
     
        <div>
            Categories: @string.Join(", ", Model.Item.GetHierarchicalTaxons("Category").Select(t=> t.Title))
        </div>

    Hope this helps.

    Regards,
    Nikola Zagorchev
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
    Answered
  3. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    29 Sep 2016
    05 May
    Link to this post
    Hi Stu,

    Were you able to achieved the desired result?

    Regards,
    Nikola Zagorchev
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  4. Stu
    Stu avatar
    3 posts
    Registered:
    08 May 2014
    05 May in reply to Nikola Zagorchev
    Link to this post
    Yes this is great, thank you!
  5. Nikola Zagorchev
    Nikola Zagorchev avatar
    424 posts
    Registered:
    29 Sep 2016
    05 May
    Link to this post
    Hi Stu,

    Glad it helps.

    Regards,
    Nikola Zagorchev
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
5 posts, 2 answered