Try our conversational search powered by Generative AI!

Get Page Categories

Vote:
 

Hi,

How, in Razor, do you get a page's Categories that have been tagged in the CMS. I cant seem to use CurrentPage - it isnt an option in my Model.

Jon

#141098
Nov 09, 2015 18:28
Vote:
 

Hi,

Did you try code like:

 @foreach (int category in this.Model.CurrentPage.Category)
    {
        var name = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<EPiServer.DataAbstraction.CategoryRepository>().Get(category).Name;
        <div>@name</div>
    }
#141099
Nov 09, 2015 19:56
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.