taxonomy_node_get_terms

Definition

taxonomy_node_get_terms($nid, $key = 'tid')
modules/taxonomy.module, line 475

Description

Find all terms associated to the given node.

Code

<?php
function taxonomy_node_get_terms($nid, $key = 'tid') {
  static $terms;

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

Drupal is a registered trademark of Dries Buytaert.