| 5 taxonomy.module | taxonomy_get_parents($tid, $key = 'tid') |
| 6 taxonomy.module | taxonomy_get_parents($tid, |
| 7 taxonomy.module | taxonomy_get_parents($tid) |
Finds all parents of a given term ID.
Parameters
$tid: A taxonomy term ID.
Return value
An array of term objects which are the parents of the term $tid, or an empty array if parents are not found.
8 calls to taxonomy_get_parents()
1 string reference to 'taxonomy_get_parents'
File
- modules/
taxonomy/ taxonomy.module, line 900 - Enables the organization of content into categories.
Code
function taxonomy_get_parents($tid) {
$parents = &drupal_static(__FUNCTION__, array());
if ($tid && !isset($parents[$tid])) {
$query = db_select('taxonomy_term_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid');
$query->addField('t', 'tid');
$query->condition('h.tid', $tid);
$query->addTag('term_access');
$query->orderBy('t.weight');
$query->orderBy('t.name');
$tids = $query->execute()->fetchCol();
$parents[$tid] = taxonomy_term_load_multiple($tids);
}
return isset($parents[$tid]) ? $parents[$tid] : array();
}
Login or register to post comments
Comments
Looks like this is:
Looks like this is: taxonomy_term_load_parents() in Drupal 8.