0

I am creating a page.tpl.php template in Drupal 7 in which I want to rearrange how certain elements of the page are laid out. Specifically I want the title of the page to appear before the tabs and messages section (which I have done) and have the content of the page appear after the tabs and messages section (this is where I run into issues). I can't find a way to just render the $page['contents'] without the title. Is there a way to achieve this in Drupal 7?

I know that the node.tpl.php template handles the node specific layout, but it doesn't allow me to layout the page like as described above.

Thanks.

1

Somethings can be done in page.tpl.php & some in node.tpl.php

Like you said, you need to make title of the node appear before tabs. You can do this in your page.tpl.php. Find $title variable as well as $tabs & arrange accordingly in your page.tpl.php. Like --

<?php if ($title) : ?>
  <h1 class="title">
    <?php print $title; ?>
  </h1>
<?php endif; ?>
<?php if ($tabs): ?>
  <div class="tabs">
    <?php print render($tabs); ?>
  </div>
<?php endif; ?>

After this you will have print render($page['content']);, where node.tpl.php comes into the scene, so arranging other things like node content, comment, links you will have to go to your node.tpl.php & arrange accordingly. More modification such as in comment & other TPLs will come into the scene like comment.tpl.php etc..

2
  • This is what I ended up doing in the end where I do not print out the node's title in the node.tpl.php file to achieve the effect I am looking for. As a caveat to others who want to achieve the same thing, you will need to use a node type specific templates so as to not hide article titles when multiple articles are listed on a page. – user5013 Sep 16 '13 at 21:22
  • You didn't specify the content type specific requirement, so I didn't mention anything of that regards in my answer. Anyway, node title is part of page.tpl.php not node.tpl.php.. – RajeevK Sep 17 '13 at 3:40

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.