Search code examples
cssdrupaldrupal-7

How to get the id of most recent polls in drupal


I am trying to make frontpage and want to show most recent poll in block programmatically. I know that a block can be placed programmatically as:

     $block = module_invoke('block','block_view', 4);
      print render($block['content']);

And now I am unable to work out how get the most recent polls id. I have tried('recent') but it doesnt work.


Solution

  • <?php $block = module_invoke('poll', 'block_view'); ?>
    <?php print render($block['content']); ?>
    

    The module_invoke function requires only 2 paramenters, the first is the module name (poll) and the second is the hook. The delta is not necessary because poll_block_info() defines only one block so there's no need to pass a delta argument (just leave the 3rd argument out)