Skip to content

Instantly share code, notes, and snippets.

@hanamizuki
Created December 18, 2012 14:14
Show Gist options
  • Save hanamizuki/4328307 to your computer and use it in GitHub Desktop.
Save hanamizuki/4328307 to your computer and use it in GitHub Desktop.
Drupal : Render a block programmatically
Drupal 6:
<?php
$block = module_invoke(‘MODULE_NAME’, ‘block’, ‘view’, MODULE_DELTA);
print $block[‘content’];
?>
Drupal 7:
this will print with title
<?php
$block = block_load(‘locale’, ‘language’);
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
print $output;
?>
this will print without title
<?php
$block2 = module_invoke(‘locale’, ‘block_view’, ‘language’);
print render($block2[‘content’]);
?>
Ref:
http://api.drupal.org/api/drupal/includes!module.inc/function/module_invoke/7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment