You are here

Panels template files using template suggestions

I ran into a problem to day working on a site, where I need to change the mark-up for some of the panes on the front page of the site. But as it turned out panels did only have one tpl file for panes namely "panels/templates/panels-pane.tpl.php", which changes the mark-up for all panes on the site . The solution was to insert the function below into template.php in my theme and using template suggestion to give me more tpl's to work with,

The function below suggest template files such as "panels-pane--.tpl.php" and "panels-pane--t.tpl.php". In my case I copied "panels-pane.tpl.php" into "panels-pane--top-right.tpl.php" and "panels-pane--featured-content.tpl.php".

* Implements hook_preprocess_panels_pane().
function hook_preprocess_panels_pane(&$vars) {
  // Suggestions base on sub-type.
  $vars['theme_hook_suggestions'][] = 'panels_pane__' . str_replace('-', '__', $vars['pane']->subtype);

  // Suggestions on panel pane
  $vars['theme_hook_suggestions'][] = 'panels_pane__' . $vars['pane']->panel;


Drupal 7 panels theming PHP

Add new comment