I am looking for a way to print node content (in my case: a CCK field) above the title in node view. Since the title comes from page.tpl.php (I'm using Zen as basis), I can't print any node content above it changing node.tpl.php. But neither can I print variables from $node in page.tpl.php. One idea is to delete the line

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

from my page.tpl.php and add it to my node.tpl.php, but I'm not sure what consequence that would have. Are there any other ways to print node content above the title?

Comments

iandickson’s picture

You can't break Drupal by messing around with the tpl files.

So long as you keep the ones that worked saved, you can repair any damage by deleting the bust ones and reloading the working ones.

So experiment, and even if you don't solve this problem, you'll learn a lot and get new ideas.

Ian Dickson

Likal.com

nimbupani’s picture

$page is TRUE if the node is displayed by itself in a page.

I havent tried this, but you can go on something like this in page.tpl.php:

<?php
  if(!$page) {
      if ($title): ?>
         <h1 class="title"><?php print $title; ?></h1>
      <?php endif;   
}

?>

and in node.tpl.php you can display the content and the title if $page is TRUE.

yan’s picture

The idea is good, but this is very strange:

When I use $page in page.tpl.php it is always 0 (or FALSE?), no matter if the node is displayed by itself in a page or not (a view for example). But in node.tpl.php, it is TRUE on the node page and FALSE on other pages. That means that I can't use if(!$page) in page.tpl.php since it is always the same. That really confuses me, but I couldn't find more information about the $page variable. Is there another variable that could indicate which page I'm on?

yan’s picture

Any more ideas on how I can manage to print content above the title in node.tpl.php?

yan’s picture

One solution I found here is to use arg() in the if-statement.