On this page
function poll_block_view
poll_block_view($delta = '')
Implements hook_block_view().
Generates a block containing the latest poll.
File
- modules/poll/poll.module, line 144
- Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function poll_block_view($delta = '') {
if (user_access('access content')) {
// Retrieve the latest poll.
$select = db_select('node', 'n');
$select->join('poll', 'p', 'p.nid = n.nid');
$select->fields('n', array('nid'))
->condition('n.status', 1)
->condition('p.active', 1)
->orderBy('n.created', 'DESC')
->range(0, 1)
->addTag('node_access');
$record = $select->execute()->fetchObject();
if ($record) {
$poll = node_load($record->nid);
if ($poll->nid) {
$poll = poll_block_latest_poll_view($poll);
$block['subject'] = t('Poll');
$block['content'] = $poll->content;
return $block;
}
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!poll!poll.module/function/poll_block_view/7.x