Accessing Classifications within Views - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Accessing Classifications within Views

  • Accessing Classifications within Views
  • 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

  • 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
     
  • 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
     
  • 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
     
  • Yes this is great, thank you!