_ctools_content_vocabulary_terms

  1. drupal
    1. 6 vocabulary_terms.inc function
    2. 7 vocabulary_terms.inc function
Drupal 7 _ctools_content_vocabulary_terms($vid, $max_depth, $depth = -1, $tid = 0)

1 call to _ctools_content_vocabulary_terms()

File

sites/all/modules/ctools/plugins/content_types/vocabulary_context/vocabulary_terms.inc, line 47

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;
}