Drupal - How to display a field before node title?

This is really quite simple with Drupal 7.

With render and hide you know have the posibility to control the placement of a single element in $content without having to print out all the items yourself like was needed in Drupal 6.

A simplified node template looks like this:

<div>
  <h2><?php print $title; ?></h2>
  <div class="content">
    <?php print render($content); ?>
  </div>
</div>

A little modification would handle your needs:

<div>
  <?php print render($content['field_name_of_image']); ?>
  <h2><?php print $title; ?></h2>
  <div class="content">
    <?php print render($content); ?>
  </div>
</div>

Using render, you can output an element. This is more clever than simply printing stuff, as Drupal will keep track of what has been rendered, to avoid the same thing being printed twice on the place. When rendering the field above the title you are also removing for what's rendered when $content is rendered.


Display Suite is also pretty cool.

Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!


Have a look at the Title module - http://drupal.org/project/title. It might prove useful for your scenario. I installed/enabled it for some reason, probably similar to yours, and it seemed to give flexibility of how to place the title field.

I have since disabled it (and am using Display Suite), so my recall might be a bit sketchy.

Tags:

Entities

Nodes

7