taxonomy_get_parents_all

Versions
4.6 – 7
taxonomy_get_parents_all($tid)

Find all ancestors of a given term ID.

▾ 2 functions call taxonomy_get_parents_all()

forum_page in modules/forum/forum.module
Menu callback; prints a forum listing.
forum_view in modules/forum/forum.module
Implementation of hook_view().

Code

modules/taxonomy/taxonomy.module, line 937

<?php
function taxonomy_get_parents_all($tid) {
  $parents = array();
  if ($tid) {
    $parents[] = taxonomy_get_term($tid);
    $n = 0;
    while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
      $parents = array_merge($parents, $parent);
      $n++;
    }
  }
  return $parents;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.