You are here

function tagadelic_node_get_terms in Tagadelic 7

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

API that returns a multidimensional array with tags given a node.

Parameters

$node: A node object.

Return value

Multi-dimensional array keyed by vocabulary id then term id with term objects as values.

File

./tagadelic.module, line 167

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;
  }
}