As default, Omega uses the h1.title in region--content.tpl.php.
When using panels, the panel title is used in $title. But what will happen if you want to use your headline inside your panel-layout? A use case might be a project where you have both sidebars in some parts of the project and panels in another part "simulating" a sidebar, for instance with block-styled content in the left panel pane, while main content goes into the right one. Now you will have the headline "within" the main content area on a sidebar display, while it's above the main content area on a panel display. If classic blocks are situated in a sidebar and block-styled content in a sidebar-like panel pane, they will now have a different upper margin relatively to the site header and the headline might also "flip" over the blocks on the left hand side.
As this is difficult to explain only using words, we have a little scheme here:
Image may be NSFW.
Clik here to view.
Our goal is that the H1 title headline "optically" behaves the same in the panel context as if we would just have a normal sidebar. So how to do this?
First, we have to add the title to the panel template.
If you use one of Omegas default panel layouts, copy and paste the layout from Omega to yourtheme/panels/layouts/
and open the *.tpl file. Add the h1 to the position where you want ot to appear (normally the main content part).
<h1 class="title" id="page-title"><?php print $display->get_title(); ?>
</h1>
($display->get_title()
will catch the title that is defined in the panel.)
For custom templates, just add this code snippet to the place you want the title to be displayed.
Now the title should be displayed at the correct position. Or, at least, one of two, as now it is probably displayed twice, since it's still in region--content.tpl.php
However, we can't just remove it from there, because it should still be displayed if we are on a non panel page.
To check if the page is displayed with panels, you can use this function.
function has_panel() {
if (panels_get_current_page_display()) {
return true;
}
return false;
}
Put this in your template.php
Copy and paste the region--content.tpl from omega to your themes template folder and add the has_panel condition to the title request.
This should look like this:<?php if ($title): ?>
Transform it to:<?php if ($title && !has_panel()): ?>
Now it should work! Don't forget to set the titles in Panels now.