Closed (fixed)
Project:
Chaos Tool Suite (ctools)
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Sep 2009 at 15:50 UTC
Updated:
24 Feb 2012 at 16:18 UTC
Hi,
I'd like to know what was the way to detect if the current page is a panel page ?
For example, a simple test like if($node) tell me if the page a node or not.
I'd like to do the same in page.tpl.php for panels, to have a different class in this case for my div surrounding $content.
Thanks to all your work !
Comments
Comment #1
Pierre_G commentedReading again my message, I'm realizing I'm not that clear and my english wasn't that good :)
I'll try to explain a bit clearlier.
In my blueprint theme (and in most themes I think), I've my pages displayed like this (I simplified) :
Let's say my body have a black background, and my panels are blocks with white backgrounds, separated by a few pixels from each others.
If I want to theme this, I'm simply adding a white background to the .panel-pane div.
But for other pages which are not ruled by panels, the content will be on a black background, that's not what I want. I want the main content part of my website to be in a white block as well.
As panels are placed in the $content part of the page (see my html code above), if I'm setting a white background to the main content part, my white panels will be all surrounded by white, and not anymore separated by the black of the body background.
(you're still following?)
So I'm looking for a solution to achieve this, and the simpliest way, I think, is to detect if this is a panel page, and to set the main content background to 'none' in this case.
I hope I was clearer this time, sorry if I'm missing a simple way to theme something like this :)
Comment #2
h-man24 commentedyou can give every panel a css-id. with that you can use the CSS workflow by
for example
Try to use the FF-Plugin Webdeveloper to find out your needed classes or ids.
Stefan
Comment #3
merlinofchaos commentedI have this in a template.php which is a hacky method to detect this:
There needs to be a better way to detect this but it does not exist yet.
Comment #4
Pierre_G commentedThanks a lot merlin, I'll give it a try when I'll have some time and give you a feedback about it.
Comment #5
ianchan commentedsubscribe
Comment #6
merlinofchaos commentedOk, I introduced a new function:
page_manager_get_current_page()I tested it like this:
One thing to note: During preprocess_page() it's too late for dsm() or drupal_set_message() to work, so you're best off adding debug messages to $vars['content'].
Comment #7
merlinofchaos commentedOr maybe $vars['messages'].
Comment #9
Pierre_G commentedThanks a lot, it works like a charm.
Added this in the class attribute of the main content div :
if(in_array('page-panel', $template_files)) print ' panel-page-wrap'; else print ' normal-page-wrap';It's giving me two classe :
panel-page-wrap if I'm on a panel
normal-page-wrap if I'm on any other page
Comment #11
OpenChimp commentedI wanted to do something like this in D7. I had very simple requirements. I'm using panels and I wanted any panels page to use a different page tpl file than the pages which are not handled by panels.
Here's what I added to the THEMENAME_preprocess_page function in template.php:
I then just created a file called page--panel.tpl.php in the same directory as my page.tpl.php file, cleared caches, and was good to go.