As the title suggest, i was wondering if it is possible to change the panel page title which is h2 by default to and h1. And how this could be accomplished.

Comments

zach harkey’s picture

You can override the default template panels-pane.tpl.php by copying it from the module (...modules/panels/templates/panels-pane.tpl.php) into your theme directory. The markup you want to change is around line 28:

  <?php if ($title): ?>
    <h2 class="pane-title"><?php print $title; ?></h2>
  <?php endif; ?>

Change those h2's to h1's, save the file and clear the theme registry.

Trunkhorn’s picture

I'm not the thread author, but I have to ask... Wouldn't that cause every Pane title to be an H1?

If so, wouldn't that clash with the purpose of H1?

merlinofchaos’s picture

Status: Active » Fixed

Ok, I'm a little confused.

The title says panel pane title.

The text says panel page title.

page titles are normally rendered by page.tpl.php, so Panels has no control over it, unless you're using panels everywhere. If you're using panels everywhere, the page title content type can select what markup it uses.

If it's pane title, then Zach answered the question adequately.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

spikeerob’s picture

If you are looking for a way of changing the pane title html in panels-pane.tpl.php depending on if the the pane is providing the panel title or not the answer lies in the $display object.

For example

  <?php if ($title): ?>
  <?php if($display->title_pane == $pane->pid) : ?>
    <h1 class="pane-title"><?php print $title; ?></h1>
  <?php else : ?>
    <h2 class="pane-title"><?php print $title; ?></h2>
  <?php endif; ?>
  <?php endif; ?>
greenavus’s picture

Thanks a lot zach. It worked

suldan’s picture

With the if statement in the panels-pane.tpl.php the h2-sequence will be printed when $title is loaded, even when the title is being overwritten and printed elsewhere on the page, i.e. in a pane with a h1 around it. Then it would look like this:

<h2 class="pane-title"></h2>
<h1>MY TITLE</h1>

I would like panels to print my nodetitle (I dont want to print $title in the page.tpl.php because I want it inside a pane) with a h1 around it and without the emtpy h2 tag. Any ideas?

marios88’s picture

Thanks Zach, worked like a charm!

Don't forget to go to theme settings and press save to load the new file!

intyms’s picture

@spikeerob
Thank you.

@suldan
The solution from #5 works for me.

I have posted the solution from #5 here too:
#1112596: An empty <h2 class="pane-title"></h2> is printing above the title.

tchi’s picture

I tried the solution from #5. But I didn't get it to work.
I copied the panels-pane.tpl.php in my theme folder and changed the code like in #5.

But, I didn't understand what settings I need on my titles to differ between h1 and h2?

I have a panels with two regions. In one region I want a h1 title-tag and in the other region a h2 title-tag.

Maybe someone can help me? Thanks.

zach harkey’s picture

What kind of panes are you trying to use? Sometimes its easier to just let panes provide their own headers.

For example, with custom content panes and blocks you can just include the header markup you want in the body of the pane. For view panes, you can put whatever header markup you want into the view's header field. If it comes down to it, you can add a custom content pane to hold a custom header.

skdrupal88’s picture

I use Panels everywhere, next code output only PAGE titles as H1, other panes have H2 title tags.

    <?php if ($pane->type == 'page_content' && $pane->subtype == 'page_content'): ?>
      <h1<?php print $title_attributes; ?>><?php print $title; ?></h1>
    <?php else: ?>
      <h2<?php print $title_attributes; ?>><?php print $title; ?></h2>
    <?php endif; ?>
Anonymous’s picture

Issue summary: View changes

I still get an empty <h2> with solution #12 and an empty <h2 class="pane-title"> with solution #5
I use Panels 3.10, not Panels everywhere. Something must have changed since 4 years ago I guess. I hope someone can point me in the right direction.

icf-vpathak’s picture

Thanks @Zach and @spikeerob your solution helped.