function panels_sections_preprocess_page in Panels Sections 7.3
Implement hook_preprocess_page
File
- ./
panels_sections.module, line 29
Code
function panels_sections_preprocess_page(&$vars) {
ctools_include('page', 'page_manager', 'plugins/tasks');
$panel = panels_sections_page_manager_page_execute(PANELS_SECTIONS_PANEL);
// We don't proceed with placing panels_sections into the page template unless
// there it is successfully rendered. If there are pages where you do not want
// panels_sections to take over, ensure no panel variants pass the selection
// rules for those pages.
if (!empty($panel)) {
if (strpos($panel, PANELS_SECTIONS_PLACEHOLDER) !== FALSE) {
// We have to escape the chevrons for the regex query
$replace = array(
'<' => '\\<',
'>' => '\\>',
);
$search = str_replace(array_keys($replace), $replace, PANELS_SECTIONS_PLACEHOLDER);
// Exploding on the first instance of the placeholder and appropriately
// placing the prefix and suffix markup around the page content
list($prefix, $suffix) = preg_split('/' . $search . '/', $panel);
$vars['page']['content']['system_main']['main']['#prefix'] = $prefix;
$vars['page']['content']['system_main']['main']['#suffix'] = $suffix;
}
else {
// There may be some use cases where the normal rendered content is
// discarded. Generally, this should be avoided as it's a potential
// performance issue.
$vars['page']['content']['system_main']['main']['#markup'] = $panel;
}
}
}