How do I override the $title_prefix that is inherited from the value of

    <h2<?php print $title_attributes; ?>><?php print $title; ?></h2> 

in panels-pane.tpl.php page. This is normally output in the page.tpl.php but since i'm using panels it becomes the above.

My stating attempt is to write a template.php preprocess function, but this adds the code to every title in the template, and just adds the h1 to the page; it does not replace the h2 with the h1 for each page title. I don't want to touch the $title value which is h2 but change $title_prefix.

// Preprocess title prefix override. h1 instead of default h2
function at_panels_everywhere_preprocess(&$vars) {
  $vars['title_prefix'] = array(
    '#type' => 'markup',
    '#markup' => '<h1></h1>',

I need to replace the $title_prefix ouput to be h1 not h2 and only for the title_prefix while within the #content region.


Potential solutions that didn't work:

http://drupal.org/project/panel_variant_page_title Changing panels-pane-tpl.php h2 to h1 as this changes all panels not the 1 page panel that needs to be h1.

Eventual solution:

Turning off Page panel titles and just hardcoded h1 tag into body field. Not ideal but there really is no working solution apparently.


You can't use _preprocess hook function if you are using panels to replace h2 with h1 because h2 is hard coded in the template file.

You need to copy panels-pane.tpl.php template file from sites/all/modules/panels/templates folder to your Drupal custom theme sites/all/themes/CUSTOM_THEME/templates.

Then edit panels-pane.tpl.php and change h2 to h1

<h2<?php print $title_attributes; ?>><?php print $title; ?></h2>


<h1<?php print $title_attributes; ?>><?php print $title; ?></h1>
  • I've done what you have recommended before asking, problem is this adds a h1 to all the panes and effectively the "page title" (title_prefix). So it reads h1 > h1, h1, h1 etc. Is there no way to set the $title_prefix separately from $title so it doesn't inherit it's value? Many thanks :)
    – phil_c64
    Mar 12 '13 at 2:17
  • well, you can play with panels-pane.tpl.php code the way you want. You can change/remove $title_prefix position they way you want it to look like. If you can post a screenshot for what you are looking to achieve it will be great.
    – Aboodred1
    Mar 12 '13 at 15:56
  • I'm sorry I can't post a image direct on here as I need a rep of 10. I've uploaded screenshots on dropbox instead. dropbox.com/s/r2q4rb176ucqrz6/panels-layout.png & dropbox.com/s/pjj071wz82fydwk/panels-firebug.png
    – phil_c64
    Mar 16 '13 at 10:42
  • I forgot to say thanks, so thanks in advance for this help, it's much appreciated.
    – phil_c64
    Mar 16 '13 at 13:03

I haven't tried it yet but it looks like a good approach:

<?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; ?>


  • If you put above code into your panels-pane.tpl.php or whatever template you use on your site (below <?php if ($title): ?>, the title for the first node on your pane will have an <h1>.
    – criscom
    Jan 7 '14 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.