Skip to content

Instantly share code, notes, and snippets.

@drushman
Created July 17, 2013 04:59
Show Gist options
  • Save drushman/6017805 to your computer and use it in GitHub Desktop.
Save drushman/6017805 to your computer and use it in GitHub Desktop.
if (isset($page['widgets'])) {
$items = array();
// Get blocks in widgets region.
foreach ($page['widgets'] as $context_block) {
if (isset($context_block['#block']) && $block = $context_block['#block']) {
$block_html_id = drupal_html_id('lms-block-' . $block->module . '-' . $block->delta);
$block_html_id = substr($block_html_id, 4);
$items[] = l($block->subject, '', array('fragment' => $block_html_id, 'external' => TRUE));
}
}
// Get lms_user-widgets block add items and put this block to sidebar_first.
if (!empty($items)) {
$build = _block_render_blocks(array('lms_user-widgets' => block_load('lms_user', 'widgets')));
$renderable = _block_get_renderable_array($build);
$renderable['lms_user_widgets']['#items'] = $items;
$page['sidebar_first'] = isset($page['sidebar_first']) ?
array_merge($page['sidebar_first'], $renderable) :
$renderable;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment