--- taxonomy_context_original.module	2008-02-06 13:18:37.000000000 -0500
+++ taxonomy_context.module	2008-07-12 23:44:27.000000000 -0400
@@ -378,10 +378,15 @@ function taxonomy_context_vocabulary_pag
     }
     if (count($vocabulary->terms)) {
       foreach(array_keys($vocabulary->terms) as $key){
+        if (variable_get('taxonomy_context_show_empty', 1) || taxonomy_term_count_nodes($vocabulary->terms[$key]->tid)) {
         $vocabulary->terms[$key]->description = node_teaser($vocabulary->terms[$key]->description);
         // Load the term to ensure it gets a format assigned.
         taxonomy_context_load('term', $vocabulary->terms[$key]);
         $vocabulary->terms[$key] = taxonomy_context_prepare($vocabulary->terms[$key], FALSE);
+        }
+        else {
+          unset($vocabulary->terms[$key]);
+        }
       }
     }
     if (count($vocabularies) > 1) {
@@ -423,6 +428,15 @@ function taxonomy_context_show_term($tid
  */
 function taxonomy_context_show_subterms($tid, $vid = 0) {
   $terms = taxonomy_get_children($tid, $vid);
+
+  if (!variable_get('taxonomy_context_show_empty', 1)) {
+    foreach ($terms as $key=>$term) {
+      if (taxonomy_term_count_nodes($term->tid) == 0) {
+        unset($terms[$key]);
+      }
+    }
+  }
+  
   $output = theme('taxonomy_context_subterms', $terms);
   return $output;
 }
@@ -464,8 +478,12 @@ function taxonomy_context_menu_tree($vid
   if ($terms) {
     $output = "<ul class=\"menu\">\n";
     foreach ($terms as $term) {
+    if (variable_get('taxonomy_context_show_empty', 1) || taxonomy_term_count_nodes($term->tid)) {
       $params = array('title' => $term->description ? strip_tags(node_teaser($term->description)) : t('View this section'));
       $link = l($term->name, taxonomy_term_path($term), $params);
+      if (variable_get('taxonomy_context_show_count', 0)) {
+        $link .=  " (" . taxonomy_term_count_nodes($term->tid) . ")";
+      }
       $children = '';
 
       $children .= taxonomy_context_menu_tree($vid, $term->tid, FALSE);
@@ -479,6 +497,7 @@ function taxonomy_context_menu_tree($vid
       else {
         $output .= '<li class="'. ($children == '' ? 'leaf' : 'collapsed') .'">' . $link . "</li>\n";
       }
+      }
     }
     $output .= "</ul>\n";
   }
@@ -582,6 +601,13 @@ function taxonomy_context_admin_settings
     '#options' => array(t('Disabled'), t('Enabled')),
     '#description' => t('Show listings of subterms (sub-categories) for current term.'),
   );
+  $form['general_settings']['taxonomy_context_show_count'] = array(
+    '#type' => 'select',
+    '#title' => t('Show term count'),
+    '#default_value' => variable_get('taxonomy_context_show_count', 0),
+    '#options' => array(t('Disabled'), t('Enabled')),
+    '#description' => t('Do you want to show the number of nodes per term?'),
+  );
   $form['general_settings']['taxonomy_context_node_block'] = array(
     '#type' => 'select',
     '#title' => t('Show nodes in block'),
@@ -596,6 +622,13 @@ function taxonomy_context_admin_settings
     '#options' => array(t('Collapsed'), t('Expanded')),
     '#description' => t('Do you want items on the menu expanded or collapsed by default?'),
   );
+  $form['general_settings']['taxonomy_context_show_empty'] = array(
+    '#type' => 'select',
+    '#title' => t('Show empty terms'),
+    '#default_value' => variable_get('taxonomy_context_show_empty', 1),
+    '#options' => array(t('Disabled'), t('Enabled')),
+    '#description' => t('Do you want to show terms if there are no nodes with them or any subterms below them?'),
+  );
 
   return system_settings_form($form);
 }
@@ -633,7 +666,11 @@ function theme_taxonomy_context_term($te
   $output .= "<div class=\"$type-container\">\n";
   $output .= "  <div class=\"$type\">\n";
   if ($term->subterm) {
-    $output .= '   <h2 class="title">' . l($term->name, taxonomy_term_path($term)) . "</h2>\n";
+    $output .= '   <h2 class="title">' . l($term->name, taxonomy_term_path($term));
+    if (variable_get('taxonomy_context_show_count', 0)) {
+      $output .= ' (' . taxonomy_term_count_nodes($term->tid) . ')';
+    }
+    $output .= "</h2>\n";
   }
   if ($term->teaser) {
     $output .= '   <div class="teaser">' . $term->teaser . "</div>\n";
@@ -678,7 +715,11 @@ function theme_taxonomy_context_vocabula
   $output = '<h3 class="title">' . l($vocabulary->name, "taxonomy/vocabulary/$vocabulary->vid") . "</h3>\n";
   $output .= "<ul>\n";
   foreach($vocabulary->terms as $term) {
-    $output .= '  <li class="vocabulary-list">' . l($term->name, taxonomy_term_path($term)) . "</li>\n";
+    $output .= '  <li class="vocabulary-list">' . l($term->name, taxonomy_term_path($term));
+    if (variable_get('taxonomy_context_show_count', 0)) {
+      $output .= ' (' . taxonomy_term_count_nodes($term->tid) . ')';
+    }
+    $output .= "</li>\n";
   }
   $output .= "</ul>\n";
   return $output;
