1

I need to call the block Poll-recent from template. I have tried this code and not work for me. I am working in Drupal 7.

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

or

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

What is my error?

Thanks for your help.

3 Answers 3

1

In D7, you will need:

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

In the case of recent poll:

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

Curiously, although defined in poll_block_info the delta is actually ignored in poll_block_view, perhaps as the poll module only provides a single block.

0

@cabita: Try adding in a fourth argument 'block_delta' and using the render function to print the output, as suggested in this detailed post on Drupal.org

Hope this helps :-)

1
  • I tried with $block = module_invoke('poll', 'block', 'view', 'recent'); and nothing.
    – cabita
    Commented Feb 20, 2012 at 15:00
0

Hope this work;

$block = module_invoke('poll', 'block_view','recent'); 
print render($block);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.