Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

EPiServer.Core.CategoryList GetCategoryName Returns Value With No Spaces

Vote:
 

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".

http://world.episerver.com/documentation/Class-library/?documentId=cms/7.5/76099C8

What's the expected behavior?

Thanks!

--Ian

#114315
Dec 09, 2014 21:21
Vote:
 

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?

#114349
Dec 10, 2014 14:31
Vote:
 

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(", ", 
                categories.ToList<Int32>()
                    .Select(i => Category.Find(i).LocalizedDescription));      

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

#114356
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.