Printing Blocks in Drupal Nodes & Theme Template Files
Today at work I was given a task to put a Simple News block into a totally different spot in a website, a node. This goes a bit out of the standard Drupal way, because technically speaking, blocks should only end up in their own regions. However Drupal's API has a very nice way of doing this and I will show you how I did it in the following post.
What you need to do is navigate to your blocks page (in Drupal 7 its /admin/structure/block and in Drupal 6 its /admin/build/block/list), and there find the block you need to output in a node or a template file. This can be done by simply clicking configure and checking the URL for an ID number. In my case it was 19.
Drupal 7 Method
<?php
$block = module_invoke('simplenews', 'block_view', 19);
print $block['content'];
?>Drupal 6 Method
<?php
$block = module_invoke('simplenews', 'block', 'view', 19);
print $block['content'];
?>For more info on the module_invoke function, head over to the Drupal API site.
