Skip to content

Instantly share code, notes, and snippets.

@pascalduez
Last active December 22, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pascalduez/6398115 to your computer and use it in GitHub Desktop.
Save pascalduez/6398115 to your computer and use it in GitHub Desktop.
Drupal 7 — Default page template with panels
<?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