You are here

function advpoll_generate_block_view in Advanced Poll 7

Same name and namespace in other branches
  1. 7.3 advpoll.module \advpoll_generate_block_view()
  2. 7.2 advpoll.module \advpoll_generate_block_view()
1 call to advpoll_generate_block_view()
advpoll_block_view in ./advpoll.module
Implements hook_block_view().

File

./advpoll.module, line 852

Code

function advpoll_generate_block_view($block, $delta) {
  $parts = explode('_', $delta);
  $nid = $parts[count($parts) - 1];
  $isBlock = false;
  $node = node_load($nid);
  $options = $node->advpoll_options[$node->language];

  // need to check to see if the nid is meant to display as a block or not.
  // It's possible the value gets switched off but the block id is still
  // assigned to a region and will display anyway.
  foreach ($options as $option) {
    if ($option['value'] == 'block') {
      $isBlock = true;
    }
  }
  if ($isBlock) {
    $block['subject'] = t('Poll');
    $block['content'] = array(
      '#markup' => drupal_render(node_view($node)),
    );
  }
  return $block;
}