You are here

function nat_get_terms in Node Auto Term [NAT] 7.2

Same name and namespace in other branches
  1. 5 nat.module \nat_get_terms()
  2. 6.2 nat.module \nat_get_terms()
  3. 6 nat.module \nat_get_terms()
  4. 7 nat.module \nat_get_terms()

Gets terms associated with a node.

Parameters

$nid: The nid of the node whose NAT terms are to be retrieved.

Return value

$return An associative array of NAT-associated term objects.

5 calls to nat_get_terms()
nat_get_term in ./nat.module
Retrieve the first / single NAT term associated with a node optionally restricted by vocabulary.
nat_get_terms_by_vocabulary in ./nat.module
Retrieve the NAT terms associated with a node restricted by vocabulary.
nat_node_load in ./nat.module
Implements hook_node_load().
_nat_delete_terms in ./nat.module
Delete associated terms from the taxonomy system. @todo Options to delete child nodes as well etc.
_nat_update_terms in ./nat.module
Update saved node-terms.

File

./nat.module, line 320
NAT - node auto term - is a helper module that automatically creates a term using the same title as a node.

Code

function nat_get_terms($nid) {
  static $term_cache = NULL;
  if (isset($term_cache[$nid])) {
    return $term_cache[$nid];
  }
  $return = array();
  $result = db_query("SELECT ttd.*\n    FROM {nat} n\n    INNER JOIN {taxonomy_term_data} ttd USING (tid)\n    WHERE n.nid = :nid", array(
    ':nid' => $nid,
  ));
  foreach ($result as $term) {
    $return[$term->tid] = $term;
  }

  // Cache result.
  $term_cache[$nid] = $return;
  return $return;
}