You are here

function hs_taxonomy_get_parents_all in Hierarchical Select 5.3

Same name and namespace in other branches
  1. 6.3 modules/hs_taxonomy.module \hs_taxonomy_get_parents_all()
  2. 7.3 modules/hs_taxonomy.module \hs_taxonomy_get_parents_all()

Alternative version of taxonomy_get_parents_all(): instead of using all parents of a term (i.e. when multiple parents are being used), only the first is kept.

1 call to hs_taxonomy_get_parents_all()
hs_taxonomy_hierarchical_select_lineage in modules/hs_taxonomy.module
Implementation of hook_hierarchical_select_lineage().

File

modules/hs_taxonomy.module, line 268
Implementation of the Hierarchical Select API for the Taxonomy module.

Code

function hs_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, array(
        reset($parent),
      ));
      $n++;
    }
  }
  return $parents;
}