Reputation: 115
What is the correct way to print a drupal block assigned to a region on a node template ex(node.tpl.php)
Upvotes: 1
Views: 119
Reputation: 27033
You can use module_invoke($module, $hook) to do so.
$module: The name of the module (without the .module extension).
$hook: The name of the hook to invoke.
Code snippet:
$block = module_invoke('module_name', 'block_view', 'block_delta');
print $block['content'];
OR
use the following code snippet:
function block_print_html($module, $block_id)
{
$block_html = "";
$block = block_load($module, $block_id);
$block_content = _block_render_blocks(array($block));
$block_build = _block_get_renderable_array($block_content);
return = drupal_render($build);
}
Upvotes: 1