I'm creating this issue to properly address the bug found in this issue: #1018726: Overriding the default panels-pane.tpl.php (the issue was for D6, not D7, and it should be closed).
From all the testing I've done, it's currently impossible to specify a template suggestion to a panel pane via a preprocess function in Drupal 7.
Tested with:
- Drupal 7.2
- Panels 3.x dev (2011-May-31 release) and Panels 3.0-alpha3
- ctools 1.0-beta1
Testing Procedure
- Copied
panels-pane.tpl.php
to my theme's directory. Inserted new HTML markup and it worked - Added the following code in my theme's template.php
<?php function mytheme_preprocess_panels_pane(&$variables) { $variables['test'] = '<h1>weird funny test</h1>'; } ?>
- Added
<?php print $test; ?>
which successfully outputted inpanels-pane.tpl.php
override. - Added
panels-pane-test.tpl.php
file in my theme's directory and added unique HTML markup to distinguish it frompanels-pane.tpl.php
file - Added following code to template.php:
<?php function mytheme_preprocess_panels_pane(&$variables) { $variables['template_files'][] = 'panels-pane-test'; } ?>
- and nothing happens once the cache is cleared.
I should mention that when doing a devel dpm of the panel pane variables in the preprocess function, there was no empty template_files
array like in Drupal 6, which I'm guessing is at the heart of the issue. Nor did I see anywhere in the array where there would be any appropriate place to specify template overrides.
Hopefully this is thorough enough to help you determine the issue, and let me know how I can help.
Thanks,
Rene
Comment | File | Size | Author |
---|---|---|---|
#16 | subtype-strtr.patch | 831 bytes | bsuttis |
#9 | add_pane_template_autodetection-1178334-9.patch | 800 bytes | jenlampton |
Comments
Comment #1
Headache CreditAttribution: Headache commentedsubscribe
Comment #2
jeff.maes CreditAttribution: jeff.maes commentedI have a working solution over here.
The difference with D6 is the way that D7 renames the template suggestions: You have to use underscores (_) in your template suggestions, which will be replaced with dashes (-).
And your template suggestion is:
Comment #3
Headache CreditAttribution: Headache commentedThank you, Jeff. It really works well.
Dunno why did I miss that point :/
Comment #4
bryancasler CreditAttribution: bryancasler commentedbookmarking this for myself
Comment #5
rhache CreditAttribution: rhache commentedFantastic! Much appreciated.
Comment #6
samhassell CreditAttribution: samhassell commentedawesome thanks!
Comment #7
jenlamptonCould we add something like this so that these template files might be detected automatically?
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedYes please. Can I get a patch?
Also, $type by itself, and then $type __ $subtype too?
Comment #9
jenlamptongood idea :) I also added "pane_" before the type and sub-type so it would match the classes.
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedI don't think the pane_ should be added to match the classes -- that's there to ensure no class collisions but in the case of a template suggestion that is not a risk.
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedI remove the $prefix and committed this.
Comment #12
jenlamptonThanks. :)
I added the prefix because the way I usually find out what to name a template file is to look at the source code and check out the classes applied. node--press-release for example. So yesterday when I was guessing at template name suggestions for panes, my first attempts had 'pane' in the type name since I had found the pane in the class name.
You're right, it't not necessary. But maybe some I'll write something up so people who won't look too deep into the code can figure out where to get a type, if not from the class.
Comment #13
Letharion CreditAttribution: Letharion commented@jenlampton It would be great if you did decide to write something up. If you do, please post here.
I assign to myself and change to docs so we don't forget to get this in later :)
Comment #14
Charles wang CreditAttribution: Charles wang commentedThank you, Jeff. It really works now,oh!
Comment #15
kharbat CreditAttribution: kharbat commentedCan't override a custom module block template inside a panel pane!
Hi I have a custom module that generates a block. I have assigned the block inside a panel pane and i'm trying to override the template of the block but it's not working.
I would really appreciate any hints.. Because this sounds like a major problem
Regards,
Comment #16
bsuttis CreditAttribution: bsuttis commentedI was having trouble getting a suggestion to work and made a fix (based on the same code in block.module) that fixed it.
The issue was that I was trying to create a .tpl.php for a Views exposed form block inside a views pane.
The suggestion Panels provided was
panels_pane__block__views--exp-search_standards-page
.Replacing the underscores with hyphens usually does the job, i.e. panels-pane--block.tpl.php worked for all blocks. But I needed even more specificity. I tried panels-pane--block--views--exp-search_standards-page.tpl.php to no avail.
After applying the patch attached, the suggestion provided is
panels_pane__block__views__exp_search_standards_page
and panels-pane--block--views--exp-search_standards-page.tpl.php works.I'm not sure if I've just gotten confused by the way the template system replaces hyphens and underscores, but it works.
Comment #17
bsuttis CreditAttribution: bsuttis commentedChanging status.
Comment #18
merlinofchaos CreditAttribution: merlinofchaos commentedIf content subtype needs that strtr, then content type almost certainly will as well.
Comment #19
MiHeath CreditAttribution: MiHeath commentedCan anyone confirm that the patch that jenlampton suggested works for views blocks. I'm still seeing an issue where if I create a view block, and load it into panels, using the block level template override is not working.
For instance, panels-pane--block.tpl.php and panels-pane.tpl.php work, but panels-pane--block--views-blockname-block.tpl is not being rendered at all.
Thoughts?
edit: bsuttis suggestion seems to help for views blocks used in panels, it's a simple fix to apply yourself, but could be useful if someone could put together a preprocess to temporarily fix this.
Comment #20
merlinofchaos CreditAttribution: merlinofchaos commentedApplied bsuttis' patch.
Comment #22
jenlamptonI've added some documentation for how to determine a panels content pane template override, here: http://drupal.org/node/1678810
Comment #23
SNaKeMe CreditAttribution: SNaKeMe commentedhi, i want to override the system type "node_view" of a panel ... but i dont get the suggestion with devel ... for the panels-pane.tpl.php file ...
Link in Panels
/admin/structure/pages/nojs/operation/node_view/handlers/node_view_panel_context_7/content
CSS-Output
Tested filenames for template corolla:
panels-pane--node--7.tpl.php
panels-pane--flexible--33.tpl.php
panels-pane--node-view--7.tpl.php
Searched on google and so on ...
Comment #24
aschiwi CreditAttribution: aschiwi commentedThere is a new module that makes using pane templates really easy: http://drupal.org/project/pps
Comment #25
rhache CreditAttribution: rhache commentedThe Clean Markup Module also makes the customization of panel region and panel pane wrappers very easy.