1 taxonomy.tokens.inc _taxonomy_token_term_parent_list($tid)

Get a list of a term's parents as a term ID to label map.

This function is intended for use exclusively for tokens.

Parameters

$tid: Taxonomy term ID.

Return value

Array of taxonomy term names keyed by term ID.:

File

core/modules/taxonomy/taxonomy.tokens.inc, line 279
Builds placeholder replacement tokens for taxonomy terms and vocabularies.

Code

function _taxonomy_token_term_parent_list($tid) {
  if (!is_numeric($tid)) {
    return array();
  }

  $parent_list = array();
  $parents = taxonomy_term_load_parents_all($tid);
  array_shift($parents); // Remove this term from the array.
  $parents = array_reverse($parents);
  foreach ($parents as $term) {
    $parent_list[$term->tid] = $term->label();
  }

  return $parent_list;
}