Sitemenu: display only terms that do have nodes associated with them

GiorgosK - February 27, 2007 - 00:42
Project:SiteMenu
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

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)

#1

theunsd - March 25, 2007 - 12:15

Thanks, 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!

#2

kbahey - March 25, 2007 - 16:36
Status:active» needs work

If someone prepares a proper tested working patch, with an optional settings, I will commit.

#3

systemparadox - November 3, 2007 - 01:02
Status:needs work» reviewed & tested by the community

Patch 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.

AttachmentSize
sitemenu-hide_empty.patch 1.92 KB

#4

kbahey - November 4, 2007 - 19:58

Anyone tested this?

Do you like this feature.

I am looking for input.

#5

xpi - December 30, 2007 - 19:39

the patch is fine for me.

but when using the Content Access module
sitemenu ignores the permissions set.
nodes hidden from anonymous roles are displayed.

#6

manoloka - January 31, 2008 - 19:26

Strange 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?

#7

manoloka - January 31, 2008 - 19:31

my mistake

I've found what I did wrong and it works like charm

Thanks :-)

#8

manoloka - September 18, 2008 - 16:56

Wouldn'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.

#9

aharown07 - November 28, 2008 - 03:23

+1 for option to see only terms w/corresponding nodes.

 
 

Drupal is a registered trademark of Dries Buytaert.