2

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

hakre
  • 193,403
  • 52
  • 435
  • 836
logii
  • 320
  • 1
  • 3
  • 15

3 Answers3

1

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.

Matt V.
  • 9,703
  • 10
  • 35
  • 56
  • p.s. - You may also want to check out the Drupal Answers Beta site. The more people who use it, the better chance it has of making it past beta: http://drupal.stackexchange.com – Matt V. May 26 '11 at 14:55
  • Hey Matt, you are right. $page_top is missing from page.tpl.php Many thanks! On top of that, thanks for the link too. drupal.stackexchange.com is just the perfect place for me to hang out. – logii May 30 '11 at 04:36
0

Not 100% sure, but you might be able to create a preprocess_node function and pass $messages to the node templates.

function template_preprocess_node(&$vars){
  $vars['messages'] = drupal_get_messages();
}
donutdan4114
  • 1,262
  • 1
  • 8
  • 16
0

Drupal 7 might render the messages before the node templates, that's why you can't see those messages.

Yes, it feels wrong to me too, and here is a little discussion and confirmation about the topic. (Closed: work as designed)

corbacho
  • 8,762
  • 1
  • 26
  • 23