Add a block within a node.tpl.php file - Drupal 7
01 Aug 2011
To insert a block directly within any node.tpl.php file, or indeed within any page.tpl.php file, you can use module_invoke.
To find the right variables to pass go to the block page within Drupal admin and hover over the 'configure' links for each block. The path tells you the module and block id that make up the first and third variables. The second one should always be 'block_view' if you want to view the block (and we do).
Example: inserting a webform block
To insert a webform block directly into a node tpl, first make sure you've enabled a block from the advanced settings on the webform itself.
Then visit 'Structure' > 'Blocks' and look at the configuration link for the webform block in question.
If the configure link is
admin/structure/block/manage/webform/client-block-44/configure then the code to place it will be:
$block = module_invoke('webform', 'block_view', 'client-block-44'); print render($block);