You are here

function _taxonomy_term_children in Drupal 6

Same name and namespace in other branches
  1. 4 modules/taxonomy.module \_taxonomy_term_children()
  2. 5 modules/taxonomy/taxonomy.module \_taxonomy_term_children()

Helper for taxonomy_term_count_nodes(). Used to find out which terms are children of a parent term.

Parameters

$tid: The parent term's ID

Return value

array An array of term IDs representing the children of $tid. Results are statically cached.

1 call to _taxonomy_term_children()
taxonomy_term_count_nodes in modules/taxonomy/taxonomy.module
Count the number of published nodes classified by a term.

File

modules/taxonomy/taxonomy.module, line 998
Enables the organization of content into categories.

Code

function _taxonomy_term_children($tid) {
  static $children;
  if (!isset($children)) {
    $result = db_query('SELECT tid, parent FROM {term_hierarchy}');
    while ($term = db_fetch_object($result)) {
      $children[$term->parent][] = $term->tid;
    }
  }
  return isset($children[$tid]) ? $children[$tid] : array();
}