How to get all categories defined from Kentico CMS?

mark json asked on March 3, 2022 04:31

Basically, I want get list of categories that defined from CMS.

For example my News categories look like this:

  • Categories:
    • News
      • Food
      • Technologies
      • Travel
    • Computers

So I want get list of categories in News category.

Can someone help me?

Recent Answers


Brenden Kehren answered on March 3, 2022 05:21

You could use the CategoryNamePath field to query your data. However if you change the name of any of the category names in that path it will break your query.

So what we do is a naming convention for the code names of the categories. For example

News.Food News.technology News.travel

Then in our query we look at the CategoryName starts with News.

We've found this to work the best AND it works across multiple environments as well as allows the user to change things around and add/remove items.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.