You are here

function _sna_blocks_nodeterms in Simple Node Archive Blocks 7

Same name and namespace in other branches
  1. 6 sna_blocks.module \_sna_blocks_nodeterms()

Get the list terms that are tagged in a Node.

Parameters

int $nid: Node id.

Return value

array Array cotaining the list of terms.

1 call to _sna_blocks_nodeterms()
_sna_blocks_archivehtml in ./sna_blocks.module
Theme the result set to HTML.

File

./sna_blocks.module, line 507
Provide a simple node archive block

Code

function _sna_blocks_nodeterms($nid) {
  $terms = array();
  $query = db_select('node', 'N');
  $query
    ->addJoin('INNER', 'taxonomy_index', 'T', 'N.nid = T.nid');
  $query
    ->addJoin('INNER', 'taxonomy_term_data', 'TD', 'T.tid = TD.tid');
  $query
    ->fields('T', array(
    'tid',
  ));
  $query
    ->fields('TD', array(
    'name',
  ));
  $query
    ->condition('N.nid', $nid);
  $query
    ->addTag('node_access');
  $query
    ->addTag('term_access');
  return $query
    ->execute()
    ->fetchAllKeyed();
}