You are here

function similarterms_taxonomy_node_get_terms in Similar By Terms 7

This function gets all taxonomy vocabularies for a certain node with option limits for Vocabularies

1 call to similarterms_taxonomy_node_get_terms()
similarterms_list in ./similarterms.module
Output the block

File

./similarterms.module, line 509
Similar By Terms module displays a block with similar content based on taxonomy terms.

Code

function similarterms_taxonomy_node_get_terms($node, $vid = NULL) {
  $terms =& drupal_static(__FUNCTION__);
  $fields = field_info_fields();
  $story_vocabs = array();
  foreach ($fields as $field_name => $field) {
    if ($field['type'] == 'taxonomy_term_reference' && !empty($field['bundles']['node']) && in_array($node->type, $field['bundles']['node'])) {
      $node_fields = field_get_items('node', $node, $field['field_name']);
      foreach ($node_fields as $item) {
        if ($vid == NULL || $item['taxonomy_term']->vid == $vid) {
          $terms[$node->vid]['tid'][$item['tid']] = $item['taxonomy_term'];
        }
      }
    }
  }
  return $terms[$node->vid]['tid'];
}