You are here

function tagadelic_node_get_terms in Tagadelic 6

Same name and namespace in other branches
  1. 5 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
Implements hook_nodeapi().

File

./tagadelic.module, line 221

Code

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