function token_taxonomy_term_load_all_parents in Token 7
Same name and namespace in other branches
- 8 token.module \token_taxonomy_term_load_all_parents()
1 call to token_taxonomy_term_load_all_parents()
- token_tokens in ./
token.tokens.inc - Implements hook_tokens().
File
- ./
token.module, line 1242 - Enhances the token API in core: adds a browseable UI, missing tokens, etc.
Code
function token_taxonomy_term_load_all_parents($tid) {
$cache =& drupal_static(__FUNCTION__, array());
if (!is_numeric($tid)) {
return array();
}
if (!isset($cache[$tid])) {
$cache[$tid] = array();
$parents = taxonomy_get_parents_all($tid);
array_shift($parents);
// Remove this term from the array.
$parents = array_reverse($parents);
foreach ($parents as $term) {
$cache[$tid][$term->tid] = entity_label('taxonomy_term', $term);
}
}
return $cache[$tid];
}