The $messages variable for page.tpl.php is generated too early in the process.
The most simple improvement is to move the generation of $messages into template_process_page() (instead of preprocess).
And when doing that, we can additionally apply the current model of process variables for consistency, which adds the benefit of allowing a contributed module to plug in an advanced rendering mechanism for $messages (i.e., a #post_render alike string/token replacement solution).
Comment | File | Size | Author |
---|---|---|---|
#1 | drupal.messages.1.patch | 1.32 KB | sun |
drupal.messages.0.patch | 1.57 KB | sun | |
Comments
Comment #1
sunShortened that comment.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedUnlike kindergarten, drupal code likes to go last. This change makes sense.
Comment #3
sunComment #4
sunProblem
MODULE_preprocess_page()
andTHEME_preprocess_page()
are not displayed.Goal
Details
THEME_preprocess_page()
to output a message on certain pages.Notes
render($variable)
within the template file itself are still not captured.API impact
hook_preprocess_page()
. Modules or themes that are implementing this hook in order to alter status/error messages need to implementhook_process_page()
instead.Comment #5
Dries CreditAttribution: Dries commentedThis make sense to me. That said, I can't think of an actual use case where a preprocess function would generate a status message. That being said, it is easy enough to create such an example.
Comment #6
webchickDries, I'm not sure what to do with this based on your comment in #5. Leaving it to you.
Comment #7
sunSome further notes:
- The outlined API change impact, although being true, can be considered moot, because $messages is a HTML string already, so all that a hook_preprocess_page() is able to do with regard to $messages is performing crazy-strange string replacements.
- Messages also means error messages. That's the primary reason for why I think this patch is important.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedWe have a developer use case at #991942: #post_render pass-through callback for kprint_r().
Comment #9
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #10
rfayBased on the API change summary I won't announce this unless otherwise directed.