You are here

function featured_content_taxonomy_node_get_terms in Featured Content 7.2

Same name and namespace in other branches
  1. 7 featured_content.module \featured_content_taxonomy_node_get_terms()

Since taxonomy_node_get_terms is no longer available and the terms are buried in the node object based on the field name, then do a query for the terms.

Based on code from: http://drupal.org/node/959984#comment-4876678 FIXME: Would be better to not have an extra query!

1 call to featured_content_taxonomy_node_get_terms()
featured_content_block_view in ./featured_content.module
Implements hook_block_view().

File

./featured_content.module, line 2305
Featured Content module for created related & featured content blocks.

Code

function featured_content_taxonomy_node_get_terms($node, $key = 'tid') {
  static $terms;
  if (!isset($terms[$node->vid][$key])) {
    $query = db_select('taxonomy_index', 'ti');
    $query
      ->fields('ti', array(
      'nid',
      'tid',
      'created',
    ));
    $query
      ->join('taxonomy_term_data', 'td', 'ti.tid = td.tid');
    $query
      ->join('taxonomy_vocabulary', 'v', 'td.vid = v.vid');
    $query
      ->condition("ti.nid", $node->nid);
    $results = $query
      ->execute();
    $terms[$node->vid][$key] = array();
    foreach ($results as $term) {
      $terms[$node->vid][$key][$term->{$key}] = $term;
    }
  }
  return $terms[$node->vid][$key];
}