You are here

function tagadelic_node_get_terms in Tagadelic 5

Same name and namespace in other branches
  1. 6 tagadelic.module \tagadelic_node_get_terms()
  2. 7 tagadelic.module \tagadelic_node_get_terms()

API that returns a multidimensional array with tags given a node

Parameters

$node. A node object.:

1 call to tagadelic_node_get_terms()
tagadelic_nodeapi in ./tagadelic.module
Implementation of hook_nodeapi You will have a nice variable in $node available for processing tags!

File

./tagadelic.module, line 165

Code

function tagadelic_node_get_terms($node) {
  static $vocs;
  if ($terms = taxonomy_node_get_terms($node->nid, 'tid')) {
    if (!isset($vocs[$node->type])) {
      $vocs[$node->type] = taxonomy_get_vocabularies($node->type);
    }
    foreach ($terms as $tid => $term) {
      if ($vocs[$node->type][$term->vid]->tags) {
        $tags[$term->vid][$tid] = $term;
      }
    }
    return $tags;
  }
}