1

This answer works when the title is printed in the node template.

However, the base node template contains this code:

<?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
<?php endif; ?>

So how do I print a field before the title when the title was already printed in the page template?

1 Answer 1

2

page.tpl.php has a $node variable on all node/%nid pages. So you have two options:

  1. You can use it directly in page.tpl.php (with the help of the field_get_items() and field_view_field() functions).

  2. You can do your messing around with $variables['node'] in a THEME_preprocess_page() function in your theme's template.php, then add your complete data to $variables[] to print the final value in page.tpl.php.

This may also help: Setting up variables in preprocess functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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