You are here

function featured_content_get_node_terms_by_vocabulary in Featured Content 7.2

Same name and namespace in other branches
  1. 7 featured_content.module \featured_content_get_node_terms_by_vocabulary()

Find all terms associated with the given node, within one vocabulary.

1 call to featured_content_get_node_terms_by_vocabulary()
featured_content_get_filtered_nids in ./featured_content.module
Get filtered node nids. Filter base on content types, users (authors) and taxonomy terms.

File

./featured_content.module, line 1830
Featured Content module for created related & featured content blocks.

Code

function featured_content_get_node_terms_by_vocabulary($node, $vid) {
  $query = db_select('taxonomy_term_data', 'td');
  $fields = array(
    'tid',
    'vid',
    'name',
    'description',
    'format',
    'weight',
  );
  if (module_exists('i18n_taxonomy')) {
    $fields[] = 'language';
  }
  $query
    ->fields('td', $fields);
  $query
    ->join('taxonomy_index', 'ti', 'td.tid = ti.tid');
  $query
    ->condition('td.vid', $vid);
  $query
    ->condition('ti.nid', $node->nid);
  $query
    ->orderBy('weight', 'ASC');
  $results = $query
    ->execute();
  $terms = array();
  foreach ($results as $term) {
    $terms[$term->tid] = $term;
  }
  return $terms;
}