Custom template for specific panes within a panel page

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
wonder95's picture

I have a front page with a custom panels layout, and I need to modify the layout of two of the panes (Our Expertise and Working With Our Communitym, http://dev.pnwsar.org/xhtml/index.xhtml is my design). All I need to do is switch the locations of the photo and the title so the title is below the photo. The template being used is panels-pane.tpl.php, so I need to create a custom template for just those two panes. How can I do that? I'm assuming there is a hook I can use to define custom templates or some way I can name the templates, but I don't know what they are. Any help would be appreciated.

Thanks.

Comments

It doesn't have template

exiled_hammer's picture

It doesn't have template suggestions (see http://drupal.org/node/1018726), you would have to create a preprocess function to do this (see http://drupal.org/node/223430)

Is very easy

trisketonni's picture

You just need to built the preprocess function theme_panels_pane(&$vars) and inside of that add something just like $vars['template_files'][] = 'panels-pane-yourtemplate';

Then the file to be created is panels-pane-yourtemplate.tpl.php

Code sample

rhache's picture

trisketonni,

Appreciate the code. There were a couple of minor mistakes (or panels worked differently then). Here's sample code that worked for me for switching the pane template in my theme's template.php.

function THEMENAME_preprocess_panels_pane(&$vars) {
  if () {
       $vars['template_files'][] = 'panels-pane-YOURTEMPLATE';
    }
}

If this version, you'll have to add the specific condition that will call this template file.

Rene

Wow, maybe I forget to say

trisketonni's picture

Wow, maybe I forget to say that you need to rename the preprocess function, as any other preprocess. In my case I use the pane subtype to select the template, so I don't need the condition.

Best.

Xabier.

Ended up writing a short blog

rhache's picture

Ended up writing a short blog post about this on our website, if anybody is interested.

http://www.northstudio.com/blog/20110410/how-create-template-overrides-s...

Rene

Correction to link

Precious, thanks Rene.

alexrayu's picture

Precious, thanks Rene.

small but important detail...

admataz's picture

Good tips and tutorial, thanks. For anyone scratching their head about this - I also couldn't get this to work at first, until I also copied the original panels-pane.tpl.php into my themes directory. Only then would my specified custom template work.

original panels-pane.tpl.php has to be also copied

mezitlab's picture

I also couldn't get this to work, until I also copied the original panels-pane.tpl.php into my themes directory.

Thanks so much for posting

ice5nake's picture

Thanks so much for posting this. I was scratching my head trying to figure out why it didn't work. Then I copied this file and ta-da!

You could also write a panels

brianmercer's picture

You could also write a panels style plugin, and then reuse it as needed.

You could also write a panels

brianmercer's picture

You could also write a panels style plugin, and then reuse it as needed.

Try this new module that

aschiwi's picture

Try this new module that makes using pane templates really easy: http://drupal.org/project/pps

Clean Markup Module

rhache's picture

You could also try the Clean markup module, which allows you to fully control the markup around a panel pane.

Panels

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: