Skip to content

Instantly share code, notes, and snippets.

@sobi3ch
Last active September 25, 2015 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobi3ch/956293 to your computer and use it in GitHub Desktop.
Save sobi3ch/956293 to your computer and use it in GitHub Desktop.
Programmatically insert block when you need it (D6)
<?php
function blue_get_block($module, $delta, $subject = '') {
$block = new stdclass; // empty object
$array = module_invoke($module, 'block', 'view',$delta );
// must be converted to an object
// @see block_list()
if (isset($array) && is_array($array)) {
foreach ($array as $k => $v) {
$block->$k = $v;
}
}
$block->module = $module;
$block->delta = $delta;
$block->region = 'blue';
$block->subject = $subject;
$block->block_html_id = "block-{$block->module}-{$block->delta}";
return theme('block', $block);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment