function _ctools_content_vocabulary_terms
1 call to _ctools_content_vocabulary_terms()
- ctools_vocabulary_terms_content_type_render in plugins/
content_types/ vocabulary_context/ vocabulary_terms.inc - Output function for the 'vocabulary terms' content type. Outputs a list of terms for the input vocabulary.
File
-
plugins/
content_types/ vocabulary_context/ vocabulary_terms.inc, line 51
Code
function _ctools_content_vocabulary_terms($vid, $max_depth, $depth = -1, $tid = 0) {
$depth++;
if ($max_depth != NULL && $depth == $max_depth) {
return array();
}
$return = array();
$query = db_select('taxonomy_term_data', 't')->fields('t', array(
'tid',
));
$query->join('taxonomy_term_hierarchy', 'h', ' t.tid = h.tid');
$query->condition('t.vid', $vid)
->condition('h.parent', $tid)
->orderBy('t.weight')
->orderBy('t.name');
$tids = $query->execute()
->fetchCol();
$terms = taxonomy_term_load_multiple($tids);
foreach ($terms as $term) {
$return[] = array(
'data' => l($term->name, 'taxonomy/term/' . $term->tid),
'children' => _ctools_content_vocabulary_terms($vid, $max_depth, $depth, $term->tid),
);
}
return $return;
}