taxonomy_node_get_terms_by_vocabulary

Definition

taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = 'tid')
modules/taxonomy.module, line 463

Description

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

Code

<?php
function taxonomy_node_get_terms_by_vocabulary($nid, $vid, $key = 'tid') {
  $result = db_query('SELECT t.* FROM {term_data} t, {term_node} r WHERE t.tid = r.tid AND t.vid = %d AND r.nid = %d ORDER BY weight', $vid, $nid);
  $terms = array();
  while ($term = db_fetch_object($result)) {
    $terms[$term->$key] = $term;
  }
  return $terms;
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.