Search code examples
piranha-cms

Categories list in Piranha CMS?


I'm using Piranha Core 8 with Aspnetcore 3. So far everything is going well. (I love Piranha!) My current problem is when building a Sidebar with a list of categories. I can't figure out how to retrieve all categories from the Api.

So far, I can get a list of posts, and perhaps iterate over them to collect the categories but this seems inefficient.

Any one know how to retrieve a list of all the categories from the cshtml pages?


Solution

  • You can get the full list of taxonomies per Archive by calling the Api.

    var categories = await api.GetAllCategoriesAsync(archiveId);
    var tags = await api.GetAllTagsAsync(archiveId);
    

    Best regards