Search code examples
phpdrupaldrupal-7drupal-themingdrupal-templates

drupal_set_message() not working in node.tpl.php template on Drupal 7


My problem is with <?php drupal_set_message('Hello World'); ?>

in node.tpl.php

In node.tpl.php, I have also done <?php print_r(get_defined_vars()); ?> to find out if the theme template is set correctly. The answer is yes.

I also have page_top and page_bottom set in my [theme].info file regions[content] = Content regions[help] = Help regions[page_top] = Page Top regions[page_bottom] = Page Bottom

$messages is outputted in page.tpl.php <div id="messages"> <?php print $messages; ?> </div>

After checking through all these, drupal_set_message() is still not working in node.tpl.php


Solution

  • The $messages variable isn't listed in the node.tpl.php documentation for Drupal 7. Do you have the $page_top variable being output in your html.tpl.php? I think that may be where the messages get output in D7.