November Happy Hour will be moved to Thursday December 5th.

Listing Categories on Page

Vote:
 

I'm building a website that will have a FAQ section.

On the FAQ page i'ld like to list all subcategories to Category named "FAQ".  Clicking on a tag will then filter the faq items with ajax (I'll figure out this later)

How do I get a list av subcategories and write out them in a view in EPiServer 7 MVC Razor?

 

Thanks in advance.

 

#74427
Aug 27, 2013 16:55
Vote:
 

This should give you all child categories (if any) for paritcular assign category for the page.

Category c = Category.Find(CurrentPage.Category.First());
CategoryCollection allChildCategories = c.Categories;

    

What you do with CategoryCollection and how you move that to ViewModel is up to you - either you access this from view itself, add it to viewmodel as collection of categories or map to some more abstract-not-related-to-EPiServer-collection and then process and render that on the view. It depends on your overall MVC app structure and approach.

#74430
Aug 27, 2013 17:55
Vote:
 

Thanks Valdis!

#74444
Aug 28, 2013 8:41
Vote:
 

Hi All, 

I am new to episerver Cms.

I need to list the sub catagories also ? 

Can anybody help me

#142280
Dec 08, 2015 14:06
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.