Skip to content

Instantly share code, notes, and snippets.

@rafinskipg
Created November 2, 2012 12:44
Show Gist options
  • Save rafinskipg/4001153 to your computer and use it in GitHub Desktop.
Save rafinskipg/4001153 to your computer and use it in GitHub Desktop.
Invoke a block and render it (Drupal 7)
/**
*Render a block
*/
function block_render($module, $block_id) {
$block = block_load($module, $block_id);
if(!isset($block->title)){
$block->title = '';
}
if(!isset($block->region)){
$block->region = '';
}
$block_content = _block_render_blocks(array($block));
$build = _block_get_renderable_array($block_content);
$block_rendered = drupal_render($build);
return $block_rendered;
}
$block_rendered = block_render('block', 'BLOCK_ID');
// print $block_rendered;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment