taxonomy_get_children
- Versions
- 4.6 – 7
taxonomy_get_children($tid, $vid = 0, $key = 'tid')
Find all children of a term ID.
Code
modules/taxonomy/taxonomy.module, line 616
<?php
function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
$query = db_select('taxonomy_term_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$query
->addTag('translatable')
->addTag('term_access')
->fields('t')
->condition('parent', $tid)
->orderBy('weight')
->orderBy('name');
if ($vid) {
$query->condition('t.vid', $vid);
}
$result = $query->execute();
$children = array();
foreach ($result as $term) {
$children[$term->$key] = $term;
}
return $children;
}
?>Login or register to post comments 