Module Monday: Absolute Messages

How to Change the Presentation of Admin and User Messages in Drupal 6 and 7

Drupal's assorted status and warning messages give users and administrators important information about what's happening on a site. They're a bit dull, though, and can easily blend in with the rest of a site's content. In addition, while most Drupal features provide copious hooks for developers to tweak, there's no simple way to hide some messages and show others, alter the text of a given message, and so on.

Absolute Messages fixes that, layering some snappy display options onto Drupal's normal message system and giving developers a set of convenient hooks to manipulate messages while before they're displayed.








Screenshot of Absolute Messages in action

The most visible change once you've installed Absolute Messages is the appearance of Drupal's system messages. They appear at the top of the screen, in color-coded boxes with their own 'Dismiss This Message' close boxes. The style is modeled after the popular Stack Overflow site, and it duplicates some of the site's behaviors as well. Long messages can be collapsed to just a few lines, expanding when the user mouses over them, and normal status messages can automatically close themselves after a few seconds.

Behind the scenes, these rules can be configured for each type of message -- Status, Warning, and Error -- ensuring that important notices don't go away while a user isn't looking.








Screenshot of Absolute Messages configuration screen

For developers who need a bit more control, Absolute Messages also provides two hooks: hook_messages_alter() and hook_message_types_alter(). They allow your modules to tweak existing messages before they're displayed, and define new types of messages. Your site's custom message type, for example, could be displayed using different CSS rules and different Absolute Messages timeout settings.

Absolute Messages is available for Drupal 6 and 7. Although it doesn't provide the handy "persistence" mechanism that the similar Persistent Dismissable Messages modules does, its presentation is smoother and the hooks it supplies give dedicated tinkerers an edge. Perhaps in the future, the two projects will merge to form the Ultimate Message Module Of Power. For now, check out Absolute Messages!

Get in touch with us

Tell us about your project or drop us a line. We'd love to hear from you!