I often use something like drupal_set_message( krumo( $row ) ); to output debug information. This is suppose to output that message within the $message area placed via the page.tpl file, however sometimes this is output in line where the code is suppose to be rendering (via a field template.)

Is there any way to make drupal_set_message output to the right place when being used in the the theme layer?

3 Answers 3


Whenever you call drupal_set_message(), or a function that outputs to the message area in a template it will not show until the next page refresh.
This is due to the fact that when the template files are being rendered, the messages to be displayed have already been pulled and rendered themselves. A refresh of the page in question after the first rendering should show the output of dpm() or what you have; just keep in mind it was for the page called before.


You do not have to call krumo directly. You can just use the helper function dpm, this will print a krumo output on the message variable.


  • What you are saying is correct, but doesn't answer the question in any way. You should post such remarks as comments and reserve answer for questions you are actually answering or partly answering.
    – googletorp
    Jun 15, 2011 at 17:32
  • 2
    @googletorp, I'm assuming the question is trying to get krumo to print in the message area. The reason for this assumption is that the user is complaining that krumo prints on the actual field markup instead of the $message. I guess thats my bad if that is not what the question is about.
    – ericduran
    Jun 15, 2011 at 17:39
  • fair enough :)
    – googletorp
    Jun 15, 2011 at 19:29

You can use drupal_get_messages to get the messages that have been set. But calls to drupal_set_message that happens after/during the page is rendered is hard to include.

You would need to theme the messages as well before adding them to the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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