Every template file in Drupal can be overridden - as long as you know the proper naming conventions.

For panel panes, your template file should be named:
panels-pane--[pane type]--[pane subtype].tpl.php

Sometimes determining the pane type and sub-type can be difficult, so here's a tip on how to get the correct names for your template files, every time.

For starters, you'll need to figure out your pane type. I usually do this by placing the following code in my theme's template.php file*:

function YOURTHEME_preprocess_panels_pane(&$variables) {
  dpm('type: ' . $variables['pane']->type);
}

Flush your theme registry (or all caches) so that this new preprocess function is located.

Refresh the page where you can see the panels content type that you'd like to override.

You should see a bunch of messages appear at the top of your screen.

Usually, just by scanning this list you'll be able to determine which type of pane you'd like to override. For the sake of this example, we'll say the search "block" was added to a panel, and we'd like to override the search panel pane template file.

Next, add an if statement for your code to identify only the panes with the type you've identified as your block. Comment out the dpm line that printed the type, and instead print the sub-type:

function YOURTHEME_preprocess_panels_pane(&$variables) {
  // dpm('type: ' . $variables['pane']->type);
  if ($variables['pane']->type == 'block') {
    dpm('subtype: ' . $variables['pane']->subtype);
  }
}

Refresh your page again (no need to rebuild the theme registry this time) and you should see a list of sub-types that only relate to the type you previously identified, and now you can construct your template override.

In this case it is panels-pane--block--search-form.tpl.php

PRO TIP: It's also SOMETIMES** possible to construct your template file name based on the classes printed in the default content pane. The default search pane has the following opening tag:

<div class="panel-pane pane-block pane-search-form">

The second class pane-block indicates that the pane type is block.

The third class pane-search-form indicates that the sub-type is search-form

So just by looking at the classes on this content pane, you can construct the template override as panels-pane--block--search-form.tpl.php

Don't forget to remove the pane- from the start of both the second and the third class when constructing your template file name.

* any use of the dpm() function will require that the devel module is turned on, and appropriate permissions are granted.

** Note that all classes use hyphens, and sometimes types and sub-types use underscores instead. The first method here is sure-fire to get you the correct name for templates. Using the classes can be unreliable.

Comments

claud811’s picture

thanks. This worked a treat!

mortendk’s picture

If you have devel module installed (as you offcouse have) then dropinside the panels-pane.tpl.php file

kpr($variables['theme_hook_suggestions']);

that gives you a dump of the theme suggestions files
then do a repleace on the _ to a ala
"panels_pane__page_title" will become "panels-pane--page-title.tpl.php"

/mdk

etiennechataignier’s picture

What happens when a ':' is in the suggestion ?
Replacing it with '-' does not work.

jerseycheese’s picture

Replacing it with "/" has worked for me, mysteriously.

gmclelland’s picture

I had a field called bid_advertisement.

So the pane's type was entity-field and the subtype was node:field-bid-advertisement

For me, I used panels-pane--entity-field--node_field-bid-advertisement.tpl.php and it worked.

Hope that helps someone.

HansKuiters’s picture

This helped, but some underscores appeared different.

pane type: entity_field
pane subtype: node:field_classificatie
template name: panels-pane--entity_field--node_field_classificatie.tpl.php