function _panels_page_check_switchers in Panels 6.2
1 call to _panels_page_check_switchers()
- _panels_page_prepare_panels_render in panels_page/
panels_page.render.inc
File
- panels_page/
panels_page.render.inc, line 47 - panels_page.render.inc Functions utilized during the panels_page render process. On any given page request, this file is lazy-loaded by panels_page itself only after it has been absolutely verified that a panels_page render should be done.
Code
function _panels_page_check_switchers(&$panel_page) {
$switchers = panels_get_switchers();
if ($switchers) {
$candidates = $list = array();
$result = db_query("SELECT name FROM {panels_page} WHERE switcher_name = '%s'", $panel_page->name);
// get a list of all pages that might switch for this one
while ($candidate = db_fetch_object($result)) {
$list[] = $candidate->name;
}
// Add default panels that apply to the list as well
foreach (panels_page_default_panels() as $page) {
if ($page->switcher_name == $panel_page->name) {
$candidates[$page->name] = $page;
}
}
if ($list) {
$candidates += count($list) > 1 ? panels_page_load_all($list) : array(
panels_page_load($list[0]),
);
}
if ($candidates) {
// separate them based on switcher type
$pages = array();
foreach ($candidates as $candidate) {
$pages[$candidate->switcher_type][$candidate->name] = $candidate;
}
// go through switcher types and switch the first one that matches.
foreach ($pages as $plugin => $candidates) {
if ($page = panels_switcher_switch($plugin, 'panel_page', $panel_page->name, $candidates)) {
$panel_page = $page;
break;
}
}
}
}
}