Forum
Can "empty" categories be hidden from output?
I am outputting a set as a list of categories like so:
<?php
perch_categories(array(
'set'=>'apptags-'.PerchSystem::get_var('language'),
'template'=>'tags.html'
));
?>
Employing their slugs the categories link to a detail page.
Some of them have been set up prematurely, which means you will get a detail page with nothing on it.
Is it possible to output only categories, that have actually been assigned to at least one item?
That's a more complex question than it sounds :) The short answer is no - I think the best you can do is add a field to the category to show it or not, and then filter on that field.
Okay thanks, Drew.
Will do as you suggested.
Hi all,
I came across this post as I'm looking to hide empty category titles as well. So, seeing Drew's suggestion on adding a field to the category and filtering on it, I've hit a brick wall....
I edited the template category.html and added the following to give me a checkbox when adding a category:
This shows a checkbox that I can turn on and off and updates the category record fine.
I then added a filter to my perch_categories array as follows:
Unfortunately, the filter then hides all the categories, which to me says that the filter isn't being matched. So I thought I'd check the database table perch2_categories for my 'enabled' column to check the value I'm filtering on as I thought it may be 'true' or '1' etc. But looking at the contents of the table, my enabled field is in catDynamicFields, and even though it says "enabled":"1" in here, it's obviously not using it.
Am I missing something obvious? Any pointers would be grand :)
Thanks!