I need to recreate a lot of pages after removing Panels from a site.
In order to print regions in node tpls, I added this to theme_preprocess_node
. That's fine but it doesn't work for custom pages.
// Get a list of all the regions for this theme
foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) {
// Get the content for each region and add it to the $region variable
if ($blocks = block_get_blocks_by_region($region_key)) {
$variables['region'][$region_key] = $blocks;
}
else {
$variables['region'][$region_key] = array();
}
}
I tried adding that to theme_preprocess_page
but it doesn't do anything.
Here is my module. The divs print fine but the regions don't get printed.
function custom_pages_menu() {
$items['classes-admin/%'] = array(
'title' => t('Classes'),
'page callback' => 'page_sidebars',
'access arguments' => array('edit field_diary_date'),
);
return $items;
}
function page_sidebars() {
$page_return = "";
$page_return .= '<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<div class="panel-pane">';
$page_return .= render($region['sidebar_left']); // or $page
$page_return .= '</div>
</div>
<div class="col-md-6">
<div class="panel-pane">';
$page_return .= render($region['sidebar_right']); // or $page
$page_return .= '</div>
</div>
</div>
</div>';
return $page_return;
}
This seems like a pretty common thing to do but google isn't giving me anything to work with. I don't want to add them to page.tpl because it's a very complex site and I only want it this way, if possible. Any help appreciated.
$region
is undeclared/null inpage_sidebars()
. I can't see how this code can possibly work.