Last active
December 22, 2015 01:39
-
-
Save pascalduez/6398115 to your computer and use it in GitHub Desktop.
Drupal 7 — Default page template with panels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Helper function to test for panel page config. | |
*/ | |
function _is_panel_page() { | |
$page = &drupal_static(__FUNCTION__); | |
if (function_exists("page_manager_get_current_page")) { | |
if (!isset($page)) { | |
$page = page_manager_get_current_page(); | |
} | |
} | |
return $page ? $page : FALSE; | |
} | |
/** | |
* Implements hook_preprocess_html(). | |
*/ | |
function HOOK_preprocess_html(&$vars, $hook) { | |
if ($page = _is_panel_page()) { | |
// Add a body class for panel pages. | |
$class = 'page-panel'; | |
} | |
else { | |
// Add a body class for default pages. | |
$class = 'page-default'; | |
} | |
$vars['classes_array'][] = drupal_html_class($class); | |
} | |
/** | |
* Implements hook_preprocess_page(). | |
*/ | |
function HOOK_preprocess_page(&$vars, $hook) { | |
if ($page = _is_panel_page()) { | |
// Add template suggestion for all panel pages. | |
$vars['theme_hook_suggestions'][] = 'page__panel'; | |
// Add template suggestion per panel page. | |
$vars['theme_hook_suggestions'][] = 'page__panel__' . $page['name']; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment