By Interactive Strategies
Jul 14, 2011

How to move $messages from page.tpl.php to node.tpl.php

For a Drupal 6 theme, here's a handy trick for moving the $messages variable from page.tpl.php to node.tpl.php. In your theme's template.php file, add the following:

function yourthemename_preprocess_page(&$variables)
{
  unset($variables['messages']);
}

function yourthemename_preprocess_node(&$variables)
{
  $variables['messages'] = theme('status_messages');
}

In the node.tpl.php template, add the following:

print $messages;

And of course, if you need to change the markup contained in the $messages variable, go ahead and add the yourthemename_status_messages function to template.php per the API documentation.

(202) 223-8656