Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, I've tried to create a custom page theme for panels. I've tried creating a file called page-panels.tpl.php but it doesn't seem to work. Is there some other way?
Comments
Comment #1
OpenChimp CreditAttribution: OpenChimp commentedI'd also love to create a single page-_____.tpl.php file that modifies all panels pages on my site. My need is fairly simple, so perhaps there is a better way to do it.
I have an existing site that uses blocks to display content in the sidebars and header and footer. I am adding a several pages that will use panels. On these pages I want to remove the sidebar content and leave it up to panels to display those blocks, but I can't use the override all blocks setting because that also removes the header and footer blocks. Should I just create a tpl for each case (page-front.tpl.php, page-programs.tpl.php, etc) or is there a better way to accomplish this since I want the same page.tpl.php template for all panel pages?
Comment #2
sunIf you use Panels Nodes, you could use page-panels-node.tpl.php.
For Panels pages, there is no common template file.
Comment #3
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedis there a way to make the panel pane theme like the blocks on drupal.org (contribution links for example):
light blue for the block
dark blue for the header
white text header
blue lettering
How would one theme panes in panels for this? Is this an addition to the css template?
Chris
Comment #5
OpenChimp CreditAttribution: OpenChimp commentedI ended up using the following:
in template.php, I define extra variables that indicate if a page is a panels page and which panels page it is.
and in page.tpl.php I can use the
I could also have simply unset the region variables like this, but this seems a little less intuitive:
I'm sure you could manipulate this code to create a page-panels.tpl.php template file, but since I really only wanted to slightly modify the template, the above solution seemed simpler.
Comment #6
Summit CreditAttribution: Summit commentedHi,
Very interested in page-panels.tpl.php template file. May be you would file the solution for this also please Michael?
Thanks a lot in advance for considering this!
Greetings, Martijn
Comment #7
fatcrobat CreditAttribution: fatcrobat commentedJust add the following code to your template.php
then simply create a file called "page-panel.tpl.php" in your theme directory and clear the cache to apply the changes.
Comment #8
Summit CreditAttribution: Summit commentedHi,
Will this also work for panels 3?
Thanks a lot for your code already shown!
greetings,
Martijn
Comment #9
fatcrobat CreditAttribution: fatcrobat commentedshould work for all panel nodes ;)
Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedPanels 2 is no longer available and is unsupported. Marking all Panels 2 issues won't fix.
Comment #11
mlconnor CreditAttribution: mlconnor commentedI'm Using Panels 3.3 and this is still an issue from what I can tell. It would be nice to have page-panel-page.tpl.php
The issue is that I need to be able to make changes to the page.tpl.php in the event that a Panels Node page is being displayed. Is there an API call or variable present that would indicate to the themer whether or not the current page is a Panels Node?
The Panels system is flexible enough that the designer of the panel can finally put the breadcrumbs and page titles in a place within the panel that makes sense for that page. Turning off the title and breadcrumbs in the page.tpl.php is then necessary.
I looked at
but the node is the proper type already, not a Panels type. In my case, it is a Press Release. There are some hacks that are scanning the page content looking for CSS but I don't think that's acceptable. The other way to do it would be to implement theme_panels_pane and set a page variable but I'm concerned that it would cause unwanted behavior when minipanels were shown.
Any thoughts?
Comment #12
mlconnor CreditAttribution: mlconnor commentedok, i figured this out. the best way to do it is to use the theme_preprocess function and check panels_get_current_page_display() to see if there is a current panel. You can also dig into the Panel there and make some determinations about how your template should react. Then you can set variables for the page so your page.tpl.php can react accordingly.
In my case, I check to see if there is a pane of type page_title. If there is then I hide the title. I also do this for breadcrumbs. It works nicely!
Comment #13
Summit CreditAttribution: Summit commentedHi, Could you may be publish your code? would be great for others to look into. Thanks!
Greetings, Martijn
Comment #14
mlconnor CreditAttribution: mlconnor commentedin my theme template...
and in my page.tpl.php
Comment #15
redben CreditAttribution: redben commentedThis doesn't seem to work. At least in my case where i use a panel as a replacement from taxonomy/term/%
i also tried page_manager_get_current_page() but it returns an empty array....
Any help would be much appreciated
Comment #16
redben CreditAttribution: redben commentedCalling page_manager_get_current_page() from inside page.tpl gets the panel (or page) but in preprocess_page it return an empty array.
weird.
Comment #17
newswatch CreditAttribution: newswatch commentedDoesn't work on D6 + Panels 3 I am afraid.
Comment #18
newswatch CreditAttribution: newswatch commentedI put this (to go with my earlier configs):
Didn't work :(
Comment #19
merlinofchaos CreditAttribution: merlinofchaos commentedWith Panels 3 you'd use page_manager_get_current_page() to retrieve the panel information. It includes quite a bit of data, so be sure to dsm() it.
Comment #20
dean.p CreditAttribution: dean.p commentedI also wanted to have a separate page.tpl.php to load for panels pages and after an hour looking online unsuccessfully for a solution, by fluke I just tried the following which seems to be working:
I created a Panels page called "Landing Page".
The URL for this page is (under settings > basic) is "landing/%tid/!term_name"
loading my page.tpl.php I saved a copy as page-landing.tpl.php (with a bit of text in the html to show me the template was in fact loading)
When I go to something like "www.mysite.com/landing/4/termname" the page-landing.tpl.php loads not page.tpl.php
This seems to work for panels and I thought it might be just reading the URL. So I tried a page-someotherurl.tpl.php for just some other node, but it did not work so it drupal is definately 'knowing' it's viewing a panel-page.
Using:
Drupal 6.17
Panels 6.x-3.5
Comment #21
Dimm CreditAttribution: Dimm commentedDrupal 6.17
Panels 6.x-3.7
node-panel-IDENTIFIER.tpl.php - not work
Comment #22
Dimm CreditAttribution: Dimm commentedIt's work!!!
Put to field Template Identifier:
IDENTIFIER
not
node-panel-IDENTIFIER.tpl.php
!!!
http://drupal.org/node/704398#comment-2733078
Comment #24
riverc CreditAttribution: riverc commentedIt seems that because the theme_page hook is implemented using page.tpl.php (This is confusing and takes awhile to figure out) this function
[x]_page($vars)
is *never* called, no matter if [x] = themename, themename_preprocess, phptemplate_preprocess, whatever.
I think some themes may change this behavior, but it looks to be default:
http://api.drupal.org/api/function/theme_page/6
The solution appears to be
1. Do not consider preprocess(vars,[hookval]) and preprocess_[hookval](vars) as coeval until you find out how [hookval] is implemented.
2. Testing behavior can be done with preprocess(vars,[hookval]) - I have used this to create a variety of template suggestions for panels. Two cases are important:
A. $hook = page, $vars['node']->type = 'panel';
B. $hook = node, $vars['node']->type = 'panel';
There are some other solutions out there for what I am about to suggest (There is a theme devel module) but you can also add a simple printout when developing to figure out what things can be templated and what are the possible template names. As was mentioned above, the $vars['template_files'] contains the template suggestions. I believe that they work in reverse order, the last template overriding any before it and so on.
You may do
and check out the results. As for getting
yourtemplate_preprocess_page()
to work, despite what it says here:
http://drupal.org/node/223440
I'm going with what I said above.
I installed the DEVEL module and it started calling yourtemplate_preprocess_page(). Whether or not my logic above makes any sense at all given that this happened, I don't know. But try it yourself and see if it works. With that in hand you can easily do something like
Else you will have to do this
The disadvantage is that you're going to be doing a bunch of extra function calls and if statements that you don't really need.
Comment #25
lord_of_freaks CreditAttribution: lord_of_freaks commentedSuscribing
Comment #26
EvanDonovan CreditAttribution: EvanDonovan commentedDecided to reopen this as a task to add to Advanced Help for Panels 3. Code snippet based on merlin's suggestion (with pointers on order of template suggestions from dekita):
You can add the following code to a module or a theme's template.php, then rebuild the theme registry, and you will have the ability to use page-panel.tpl.php or, more specifically, page-PANEL-NAME.tpl.php (where PANEL-NAME is the machine name of the panel in the Panels configuration):
I'll try to submit an Advanced Help patch for this in a while, but wanted to at least post the snippet in the hopes that others would find it useful.
Comment #27
Sol Roth CreditAttribution: Sol Roth commentedAny major changes needed to use this with D7?
Comment #28
drecute CreditAttribution: drecute commentedin Drupal 7, this worked:
I'm basically changing page templates based on whether the current page menu item is contained in a specific Drupal menu.
Comment #29
LTech CreditAttribution: LTech commentedusing Drupal 7
I copied page.tpl.php and renamed it page--panel.tpl.php. I then added echo "This is a test"; so I can test it out.
I then added to the end of my template.tpl.php file:
function Themename_preprocess_page(&$variables) {
// if this is a panel page, add template suggestions
if($panel_page = page_manager_get_current_page()) {
// add a generic suggestion for all panel pages
$variables['theme_hook_suggestions'][] = 'page__panel';
// add the panel page machine name to the template suggestions
$variables['theme_hook_suggestions'][] = 'page__' . $panel_page['name'];
//add a body class for good measure
$body_classes[] = 'page-panel';
}
}
But nothing happens when I do the above steps. What am I doing wrong?
I would like some code to the header of all my panel pages.
Thanks so much
Comment #30
LTech CreditAttribution: LTech commentedany ideas why it isn't working? I'm not sure I named the template files correctly.
Is the machine name for my panel node_view? (This is what is under the name column under structure/pages).
Should the file be named page--node-view.tpl.php? Or page--panel-node-view.tpl.php
and where should I put the file? under themename/ or themname/templates
Comment #31
LTech CreditAttribution: LTech commentedI got it working finally!
For drupal 7
in template.php:
and I created a files under ThemeName/templates
page--node_view_artist.tpl.php and
page--node_view_product.tpl.php
I hope this helps someone, it took me a long time to figure it out!
Thanks for your help
Comment #32
adixb CreditAttribution: adixb commentedHere is the Drupal 6 version:
Filenames follow D6 standards: page-node_view-product.tpl.php
Comment #33
robinthakur CreditAttribution: robinthakur commentedWould I do the same thing if I'm overriding nodes of a specific content type? I just want to change the background on nodes of a specific type rather than on ALL panels. I have a javascript background rotator installed and need to override this for a particular page which uses panels layouts for this content-type's node display. I've tried altering the CSS for background, but this only works until the background rotator loads. I therefore want to remove the background rotator entirely but only for panels containing this specific content type, and therefore need the page layout...
Thanks,
Rob
Comment #34
N20 CreditAttribution: N20 commentedThis worked for me in D7:
you can then just copy
page.tpl.php
and rename it for example to:page--node.tpl.php
for all/node/%node
pages, so basically the node pagesor
page--user.tpl.php
for all/user/%user
for user profile pagesetc.
Comment #35
japerryClosing for D6.