1 taxonomy.module taxonomy_term_load_parents_all($tid)

Find all ancestors of a given term ID.

File

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

Code

function taxonomy_term_load_parents_all($tid) {
  $cache = &backdrop_static(__FUNCTION__, array());

  if (isset($cache[$tid])) {
    return $cache[$tid];
  }

  $parents = array();
  if ($term = taxonomy_term_load($tid)) {
    $parents[] = $term;
    $n = 0;
    while ($parent = taxonomy_term_load_parents($parents[$n]->tid)) {
      $parents = array_merge($parents, $parent);
      $n++;
    }
  }

  $cache[$tid] = $parents;

  return $parents;
}