Posted by wonder95 on January 14, 2011 at 5:05pm
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
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
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
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
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
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
The path to the blog post is now https://www.northstudio.com/blog/how-create-template-overrides-specific-...
Precious, thanks Rene.
Precious, thanks Rene.
small but important detail...
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
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
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
You could also write a panels style plugin, and then reuse it as needed.
You could also write a panels
You could also write a panels style plugin, and then reuse it as needed.
Try this new module that
Try this new module that makes using pane templates really easy: http://drupal.org/project/pps
Clean Markup Module
You could also try the Clean markup module, which allows you to fully control the markup around a panel pane.