Accessing Classifications within Views

Posted by Community Admin on 05-Aug-2018 18:39

Accessing Classifications within Views

All Replies

Posted by Community Admin on 14-Apr-2016 00:00

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

Posted by Community Admin on 02-May-2016 00:00

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
 

Posted by Community Admin on 05-May-2016 00:00

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
 

Posted by Community Admin on 05-May-2016 00:00

Yes this is great, thank you!

Posted by Community Admin on 05-May-2016 00:00

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
 

This thread is closed