You are here

function similar_block_view in Similar Entries 7

Implements hook_block_view().

File

./similar.module, line 242
Module that shows a block listing similar entries. NOTE: Uses MySQL's FULLTEXT indexing for MyISAM tables.

Code

function similar_block_view($delta = '') {
  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) != 'edit') {
    $node = node_load(arg(1));
  }
  else {
    return;
  }
  $similar_node_types = variable_get('similar_node_types', _similar_published_node_types());
  if ($node->nid > 0 && !empty($similar_node_types[$node->type])) {
    unset($similar_node_types);

    // The subject is displayed at the top of the block. Note that it should
    // be passed through t() for translation.
    $block['subject'] = t('Similar entries');
    $block['content'] = theme('similar_content', array(
      'node' => $node,
    ));
  }
  return empty($block['content']) ? '' : $block;
}