I frequently use Panels for system and custom pages. In page.tpl.php
,
the whole Panels layout is dumped into the $content
variable in the primary
block region, which may not serve the needs of the design. My custom Panels
layouts often built on the UI defined in page.tpl.php
, so I like
using an alternate template suggestion for those pages which has less structure,
leaving Panels more freedom to take over the page completely.
<?php
/**
* Implements theme_preprocess_page()
*/
function tsmithcreative_preprocess_page(&$variables) {
// Call a stripped down "page--panel.tpl.php" when Panels
// covers the entire layout. Otherwise, the standard
// page.tpl.php contains the two column structure with
// Drupal's block layout.
$panel = panels_get_current_page_display();
if ( isset($panel) && !empty($panel->layout) ) {
$variables['theme_hook_suggestions'][] = 'page__panel';
}
}
This can be a faster and lighter weight alternative to activating Panels-based overrides for all system pages or using a solution like Panels Everywhere.
The panels_get_current_page_display
returns useful information about the Panels display as an object, including a
layout
property.
In template_preprocess_page
,
we can declare additional theme hook suggestions to use other templates. This
example (in use on this site, actually) adds page--panel.tpl.php
for any
Panels layout, but could easily be adapted for conditional templates based
on layout.