Printing the drupal messages in page.tpl.php is easy:
<?php print render($messages); ?>
How can I go about doing a similar thing in my Panel layouts?
Notes:
- I realise there is 'status messages' pane you can use - I wish to avoid this since admin staff will forget to include it on new pages
- I definitely wish to do it in the Panel template because there is a section above where the messages should display that is set by the admin staff
- I have tried simply putting that code into
mylayout.tpl.php
, it didn't work
Here's an example of what I am trying to do:
Is there something I can do in a pre-process function to get this to work?
EDIT:
Thanks to @Beebee I rediscovered the template_preprocess_LAYOUT function in my layout's .inc file and added
$variables['messages'] = drupal_get_messages();
now both $variables['messages']
and $messages
exist when the template is called but they contain an array of messages rather than the usual rendered output in a string.
print render($messages);
inmylayout.tpl.php
without doing any preprocessing?$messages
will be available in page templates because it gets set in template_preprocess_page. I think you'll have to preprocess your panels layout and set$variables['messages'] = drupal_get_messages();
, and then you should have the$messages
variable available on your layout template.