Page 1 of 1
Hide Child Categories in the Sidebar
Posted: Fri Mar 17, 2006 9:36 pm
by williamts99
I was wondering, is there a way to hide all of the child categories from showing up when all of the parent categories are displayed. For example, if you have 10 parent categories, and each one has 5 child categories, that would be a lot to show all at once. Is there a way to make it where the child categories will only show up when a parent category is selected? Hopefully it is just a click away and I am just missing where the setting is.
Thanks
Will
Re: Hide Child Categories in the Sidebar
Posted: Sun Mar 19, 2006 12:40 pm
by garvinhicking
There is a plugin, DHTML category menu which could do that, it's javascript driven and you might want to try it out?
I think in recetn 1.0 versions the categories default plugin has a lot of config options, did you try them all?
Regards,
Garvin
Hide child entries
Posted: Tue Jul 18, 2006 2:45 pm
by mpfeiffer
V 1.0 of the plugin has a lot of options and most of them will help. But one option is missing:
Hide the child categories
similar to
Hide the selected parent category?
If this option could be implemented, it´s perfect (for me).
regards
M.Pfeiffer
Re: Hide child entries
Posted: Tue Jul 18, 2006 4:02 pm
by garvinhicking
Hi!
Could you describe a bit in detail what you want to achieve? Are you talking about the serendipity_plugin_dhtml_categories plugin?
Regards,
Garvin
Posted: Tue Jul 18, 2006 7:57 pm
by mpfeiffer
No, not the DHTML-Plugin but the Category-Standard-Plugin.
What i ´m meaning is to show only the entries from the actually selected categories and not the content from the child categories
Example:
Test
- Test1
- - Test2
In Test is 1 entry, in Test1 3 entries and in Test2 are 2 entries.
If i select for example categorie test1 i only want to see the 3 entries from Test1 and not the entries from Test2. Today i see in this case 5 entries.
I´ve already checked the sourcecode from the plugin, i think this might not be a big change
Of course i can solve this with the html-nugget, but i like the standard categoroy plugin
regards
M.P.
Posted: Thu Jul 20, 2006 10:45 am
by garvinhicking
Hi!
Ah. This is serendipity core functionality. It has nothing to do with the sidebar plugin.
Can you explain in which case this behaviour is not wanted? Usually people are very fond of the fact how subcategories fold...
It could be patched in the core without too much work, though...
Best regards,
Garvin
Posted: Thu Jul 20, 2006 1:29 pm
by mpfeiffer
If possible you can make as an configurable option for the individuell categories (like hide parent category) or for the whole plugin.
If it is for the whole block, i by myself don´t need exceptions, but others may need this.
regards
M.P.
Posted: Thu Jul 20, 2006 1:51 pm
by garvinhicking
Uhm, did you get that I said the functionality is totally and completely independent from the sidebar plugin?
This would need to be configured in serendipity core, the sidebar plugin couldn't (easily) handle this at all.
Technically it would be very hard to make this functionality only disable for specific categories, because then one additional DB query would need to be performed for every page.
It all boils down to the file include/functions_entries.inc.php, function serendipity_getMultiCategoriesSQL(). You actually would need to replace that whole function with something like this:
Code: Select all
function serendipity_getMultiCategoriesSQL($cats, $invert = false, $no_children = true) {
global $serendipity;
$mcategories = explode(';', $cats);
$cat_sql_array = array();
foreach($mcategories AS $categoryid) {
$categoryid = (int)$categoryid;
if ($categoryid != 0) {
if ($no_children) {
$cat_sql_array[] = " (c.categoryid " . ($invert ? "!" : "") . " = " . $categoryid . ')';
} else {
$cat_sql_array[] = " (c.category_left " . ($invert ? " NOT " : "") . " BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid)) . ')';
}
}
}
return '(' . implode(($invert ? ' AND ' : ' OR '), $cat_sql_array) . ')';
}
If you were to make the behaviour dependant on the parent category, you would:
1. Add a new DB colum "show_parents" to the serendipity_categories table
2. Make the function from above check if "show_parents" of the current category is set to "1" - if yes, set $no_children = false, if not, set it to true.
3. Implement the ability to set the property per category in the "Categories" admin section.
Maybe this could be done with some sub-select or some more advanced AND/ORing to prevent one more DB lookup, but it would still make the query more complex. Disabling to show children categories would be much easier, but if that doesn't help you at all, you might rather want to modify the code manually?
Best regards,
Garvin
Posted: Thu Jul 20, 2006 4:27 pm
by mpfeiffer
Hi Garvin,
thanks for the quick reply. I have changed the code and it works fine.
This kind of solution is absolutely enough for me, i don´t really need this for individuell categories.
best regards
Michael