Function : Administer > Content management > Content
Drupal path : admin/content/node

The category filter ignores vocabularies with only one term.
This means that :
1.) The category filter is not displayed unless you define a vocabulary with at least two terms.
2.) If more vocabularies exist, those with only one term do not appear in the category filter selector.

The same happens with the Advanced search function.

The cause of this is in taxonomy.module function taxonomy_form_all()
(comment is mine) :

function taxonomy_form_all($free_tags = 0) {
  $vocabularies = taxonomy_get_vocabularies();
  $options = array();
  foreach ($vocabularies as $vid => $vocabulary) {
    if ($vocabulary->tags && !$free_tags) { continue; }
    $tree = taxonomy_get_tree($vid);
    if ($tree && (count($tree) > 1)) {   /* vocabularies with only one term are skipped */
      $options[$vocabulary->name] = array();
      foreach ($tree as $term) {
        $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name;
      }
    }
  }
  return $options;
}

I tested the following modification (see comment):

function taxonomy_form_all($free_tags = 0) {
  $vocabularies = taxonomy_get_vocabularies();
  $options = array();
  foreach ($vocabularies as $vid => $vocabulary) {
    if ($vocabulary->tags && !$free_tags) { continue; }
    $tree = taxonomy_get_tree($vid);
    if ($tree) {   /* Process vocabularies with at least one term. Ignore empty vocabularies. */ 
      $options[$vocabulary->name] = array();
      foreach ($tree as $term) {
        $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name;
      }
    }
  }
  return $options;
}

I was not able to find any side-effects, and now all vocabularies with at least one term appear in the content filter selector.

Many thanks for comments/reviews
(patch against HEAD attached)

CommentFileSizeAuthor
#2 taxonomy_filter.patch861 bytesriccardoR
taxonomy_module_1.patch759 bytesriccardoR
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drumm’s picture

Status: Needs review » Needs work

Looks like taxonomy_get_tree() always returns an array, so I do not think what was left of the if statement is actually useful. I think we do explicitly want to make sure there is one term, so count(...) > 0 would be the condition to use.

riccardoR’s picture

Status: Needs work » Needs review
FileSize
861 bytes

@drumm: thanks for your review. You are definitely right.
Rerolled with your commentary against current 5.x-dev

Dries’s picture

Status: Needs review » Reviewed & tested by the community

Committed this patch to CVS HEAD. I think we might want to backport this patch to D5.

drumm’s picture

Committed to 5.x.

drumm’s picture

Status: Reviewed & tested by the community » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)