Try our conversational search powered by Generative AI!

EPiServer.Core.CategoryList GetCategoryName Returns Value With No Spaces


Hi There,

I'm trying to get the "human-readable" values for Category for a given page. If I use the CategoryName(Int32) method to retrieve a category with spaces, it's being returned with no spaces.

So for example, the Category in the page is defined as "About Us". Its id is '2'.

When I get currentPage.Category.CategoryName(2) the return value is "AboutUs".  In contrast, when I view the category in the EPiServer admin interface for the page, it's showing as "About Us".

What's the expected behavior?



Dec 09, 2014 21:21

If you define category in UI setting Name and DisplayName, they actually in API are mixed up a bit - Name is Name and DisplayName is Description. Maybe you are misusing them on API side?

Dec 10, 2014 14:31

There doesn't seem to be any way of getting at that information based on the EPiServer API documentation.

Ah, okay I think I found the magical incantation. 

            var categories = currentPage.Category;
            this.CategoryString = string.Join(", ", 
                    .Select(i => Category.Find(i).LocalizedDescription));      

I wonder why on Earth there's no currentPage.Category.CategoryDescription(2) method. 

Dec 10, 2014 16:24
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.