function taxonomy_get_parents_all in Drupal 7
Same name and namespace in other branches
- 4 modules/taxonomy.module \taxonomy_get_parents_all()
- 5 modules/taxonomy/taxonomy.module \taxonomy_get_parents_all()
- 6 modules/taxonomy/taxonomy.module \taxonomy_get_parents_all()
Find all ancestors of a given term ID.
3 calls to taxonomy_get_parents_all()
- forum_forum_load in modules/
forum/ forum.module - Returns a tree of all forums for a given taxonomy term ID.
- forum_node_view in modules/
forum/ forum.module - Implements hook_node_view().
- taxonomy_field_validate in modules/
taxonomy/ taxonomy.module - Implements hook_field_validate().
1 string reference to 'taxonomy_get_parents_all'
- taxonomy_terms_static_reset in modules/
taxonomy/ taxonomy.module - Clear all static cache variables for terms.
File
- modules/
taxonomy/ taxonomy.module, line 1041 - Enables the organization of content into categories.
Code
function taxonomy_get_parents_all($tid) {
$cache =& drupal_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_get_parents($parents[$n]->tid)) {
$parents = array_merge($parents, $parent);
$n++;
}
}
$cache[$tid] = $parents;
return $parents;
}