Skip to content

Instantly share code, notes, and snippets.

@jameswilson
Created July 17, 2014 13:27
Show Gist options
  • Save jameswilson/c8cf2927713c7f144f31 to your computer and use it in GitHub Desktop.
Save jameswilson/c8cf2927713c7f144f31 to your computer and use it in GitHub Desktop.
Panel layout body class
// Place this in mymodule.module
/**
* Implements hook_panels_pre_render().
*/
function mymodule_panels_pre_render($panels_display, $renderer) {
// Add a body class for all panel layouts present on a given page. This
// functionality piggy-backs on Panels 'body_classes_to_add' functionality.
// And let's us do clever things like null out the max-width of container
// regions on certain layouts where we need region wrappers inside the panel
// to reach the edge of a page, for theming purposes.
$panel_body_css = &drupal_static('panel_body_css');
$layout_class = drupal_html_class($panels_display->layout);
if (!empty($panel_body_css['body_classes_to_add'])) {
$panel_body_css['body_classes_to_add'] .= ' ' . $layout_class;
} else {
$panel_body_css['body_classes_to_add'] = $layout_class;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment