Forum
Showing sub-categories
I have a 2 sets of categories for my blog. blog - > news + subcategories & blog - > contest + subcategories
I try to use perch_blog_categories() to display sub-categories only from "news" and on other page sub-categories only from contest. But every time I try diffrent solutions found here on forum, I always get full list of categories.
Using code below, it always shows me categories from contest also.
perch_blog_categories(array(
'set' => 'blog/news/'
));
perch_blog_categories(array(
'set' => 'news'
));
Will be thankful for any suggestions, I pretty sure it is something simple I'm missing here. Thanks.
Is this blog-specific, or should you be using
perch_categories()
?Drew, it does not need to be blog-specific, but using perch_categories( )
gives me the same results as perch_blog_categories(), all categories are displayed.
Is that a valid set slug? It doesn't look like it is.
I have copied this one from admin panel (path in categories) twice to make sure it is correct :) but still the same results.
It looks like a category path, not a set slug. A set slug example would be
blog
, notblog/news/
I have created new Set called "Test" I can display only sub-categories for Test - set using
but how can I achieve this for blog categories?
Looks like my misunderstanding. Then one more time, I have a Set called Blog and in Blog I have to 2 main categoires News and Contest. These categories have sub-categories. I want to display sub-categories only for News
I think this should work, but it does not. It gives me empty results.
Sometimes it's easiest to add
<perch:showall />
to the template which in this case is/perch/templates/categories/category.html
so you will know what fields are available, and what the values are of those fields.This will make troubleshooting a bit easier if you know what's happening at runtime...
category.html (default template shown with showall example added)
Thanks Robert for suggestion, I know catPath exists in category template. But I do not know how I can filter this categories This one gives me empty results.
Thanks Robert! Your suggestion was very helpful :) I achived it by filtering it by catParentID