19 July 2011

This snippet shows you how to load a blocks content programmatically. You can use this way to display a block anywhere you want.

Source code viewer
  1. // Replace module_name with module which generates the block.
  2. // Replace block_name with name of the block that you wish to show.
  3. $block = module_invoke('module_name', 'block_view', 'block_name');
  4. echo $block['content'];
  5.  
  6. // Real example how to use this method with webform blocks:
  7. $block = module_invoke('webform', 'block_view', 'client-block-3853');
  8. print $block['content'];
Programming Language: PHP