--- 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 = "\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 .= "
\n"; $output .= "
\n"; if ($term->subterm) { - $output .= '

' . l($term->name, taxonomy_term_path($term)) . "

\n"; + $output .= '

' . l($term->name, taxonomy_term_path($term)); + if (variable_get('taxonomy_context_show_count', 0)) { + $output .= ' (' . taxonomy_term_count_nodes($term->tid) . ')'; + } + $output .= "

\n"; } if ($term->teaser) { $output .= '
' . $term->teaser . "
\n"; @@ -678,7 +715,11 @@ function theme_taxonomy_context_vocabula $output = '

' . l($vocabulary->name, "taxonomy/vocabulary/$vocabulary->vid") . "

\n"; $output .= "\n"; return $output;