You are here

function taxonomy_xml_get_term_ancestors in Taxonomy import/export via XML 6.2

Same name and namespace in other branches
  1. 7 taxonomy_xml.process.inc \taxonomy_xml_get_term_ancestors()

Return a list of all terms in the ancestry chain of the given term.

List list includes all parents from multi-inheritance.

Use this to check before setting up a parental chain that may loop

Return value

array keyed by tid, but in no specific order.

See also

taxonomy_get_parents_all()

1 call to taxonomy_xml_get_term_ancestors()
taxonomy_xml_set_term_relations in ./taxonomy_xml.module
Given a list of terms, set the related-terms and structure, and save again

File

./taxonomy_xml.module, line 1577
This module makes it possible to import and export taxonomies as XML documents.

Code

function taxonomy_xml_get_term_ancestors($term) {
  $parents = taxonomy_get_parents_all($term->tid);

  // This always includes self, so skip that.
  array_pop($parents);

  // index by tid
  $ancestors = array();
  foreach ($parents as $parent) {
    $ancestors[$parent->tid] = $parent;
  }
  return $ancestors;
}