I tweaked the code to do just that if anybody is interested
//line 268
if ($get_node_count && $mode == 'page') {
//becomes
if ($get_node_count ) {
//and lines 439-444
if ($term->depth < $tree[$m+1]->depth) {
$output .= "<li class=\"expanded\">". $link ."\n";
}
else {
$output .= "<li class=\"leaf\">". $link ."</li>\n";
}
//become
if ($term->count) {//addition
if ($term->depth < $tree[$m+1]->depth) {
$output .= "<li class=\"expanded\">". $link ."\n";
}
else {
$output .= "<li class=\"leaf\">". $link ."</li>\n";
}
}//addition
or it could also be incorporated in the code with a configuration setting of whether to display terms with no nodes
(but I am not familiar with the drupal code yet to do it)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | sitemenu-hide_empty.patch | 1.92 KB | systemparadox |
Comments
Comment #1
theunsd commentedThanks, this really helped me a lot. It would be nice if the developer built that in as a configuration setting. I'm sure we aren't the only 2 guys who have needed this. Thanks again!
Comment #2
kbahey commentedIf someone prepares a proper tested working patch, with an optional settings, I will commit.
Comment #3
systemparadox commentedPatch attached. Unlike the modification above it still displays the nodes. Adds an option to the settings page.
Empty vocabularies will still be shown, but I don't think this matters. You could always disable them manually in the config page.
Comment #4
kbahey commentedAnyone tested this?
Do you like this feature.
I am looking for input.
Comment #5
xpi commentedthe patch is fine for me.
but when using the Content Access module
sitemenu ignores the permissions set.
nodes hidden from anonymous roles are displayed.
Comment #6
manoloka commentedStrange I've just changed it as you say and what it happens it's completely the opposite;
it only display terms that do NOT have nodes associated with them
what did I do wrong?
Comment #7
manoloka commentedmy mistake
I've found what I did wrong and it works like charm
Thanks :-)
Comment #8
manoloka commentedWouldn't it be great to add this function as an option.
That's it, somewhere you can tick to choose whether to see them all or only the ones that have something in it.
Comment #9
aharown07 commented+1 for option to see only terms w/corresponding nodes.