function panels_sections_takeover in Panels Sections 6
Same name and namespace in other branches
- 6.2 panels_sections.module \panels_sections_takeover()
This function must be called once from template.php it will determine which panel to use based by querying panels_page and panels_sections, then load the correct panel and do some text replacing to convert %CONTENT% to the page content so you can use panels on non-node pages
Parameters
unknown_type $vars:
File
- ./
panels_sections.module, line 438 - Allows you to define panels_sections of your site and apply s to those panels_sections.
Code
function panels_sections_takeover(&$vars, $debug = FALSE) {
/*
* Panels management
*/
//ask panels_page if there is a page specific panels_page for this path
$current_panel = panels_page_get_current();
if (isset($current_panel->pid)) {
$msg = 'Page specific';
//$panel = $vars['content'];
$panel = panels_page_view_page($current_panel->pid, false, isset($vars['node']) ? $vars['node']->nid : null);
}
else {
//query panels_section module for correct section
$panels_section = panels_sections_in_section();
//if panels_section returns a panels_page, take over current page
if ($panels_section->panels_page) {
$msg = 'Panel: ' . $panels_section->name;
$current_panel = panels_page_load($panels_section->panels_page);
$panel = panels_page_view_page($current_panel, false, isset($vars['node']) ? $vars['node']->nid : null);
}
}
$vars['panel_current'] = $current_panel->name;
$vars['panel_edit'] = l($current_panel->name, 'admin/panels/panel-page/' . $current_panel->name . '/edit/content');
//output the message so I know what's going on
if ($debug) {
dpr($msg);
}
$in_panel = '';
if (strpos('x' . $panel, '%CONTENT%')) {
// Build up some content
if (isset($vars['help'])) {
if (strlen($vars['help']) > 35) {
// Yes josh you hate hard-coding, me too.
$in_panel .= $vars['help'];
}
$vars['help'] = '';
}
if (isset($vars['messages'])) {
$in_panel .= $vars['messages'];
$vars['messages'] = '';
}
if (isset($vars['title'])) {
drupal_set_title($vars['node']->title);
if ($vars['title'] == 'Empty' && isset($vars['node'])) {
// Who knows where this problem started... ??
$vars['title'] = $vars['node']->title;
}
$in_panel .= '<h1 class="title">' . $vars['title'] . '</h1>';
$vars['title'] = '';
}
if (isset($vars['tabs'])) {
if (!user_access('view simplemenu')) {
// Only show tabs if the user doesn't have simplemenu - tabs are pushed into 'current page'
$in_panel .= '<div class="tabs">' . $vars['tabs'] . '</div>';
}
// $vars['tabs'] = '';
}
if (isset($vars['node'])) {
// wrap a nice node type div for dan
$vars['content'] = "\n" . '<div class="dan-rocks panel-pane-' . $vars['node']->type . '">' . $vars['content'] . "</div>\n";
}
$in_panel .= $vars['content'];
$vars['content'] = '';
$panel = str_replace('%CONTENT%', $in_panel, $panel);
}
//stuff the panel
$vars['content'] = $panel;
}