Download & Extend

Persistent Dismissable Messages

Have you ever wished for a very simple way to have a status message (set by drupal_set_message()) persist across multiple pages and also be dismissable? Well, you've come to the right place, because PDMs (persistent dismissable messages) is what we're selling.

The PDM module takes over all dsms (messages set by drupal_set_message()) and modifies them to become dismissable (similar in some respects to the Absolute Messages module. Each message appears in its own div and visual area (as opposed to the default in Drupal, which is to group all warning, status and error messages together) and can be removed by clicking a 'hide' link.

But wait! There's more!

Developers can make use of a fantastic function provided by the module called: pdm_create_message(). This function will allow them to create status messages with even more functionality.

PDM Create Message Options:

  • type: The same as the 'type' for drupal_set_message(). This affects class output and theming.
  • pdm_type: This is a custom setting where you can enter any string you wish. This will be used in the future to allow filtering of existing/archived messages. Its function is identical to the first parameter of the watchdog() function.
  • repeat: The same as 'repeat' for drupal_set_message(). This affects whether or not the message will repeat if the exact same message re-occurs.
  • persist: If set to TRUE (the default), the message is saved to the database and will show until dismissed, or it expires. If it is set to FALSE the message is transient and will not be stored.
  • persist_count: If set to a value greater than 0 (the default is 0) the message will display only for the number of times set and then expire.
  • persist_time: If set to a value greater than 0 (the default is 0) the message will display for that many seconds from when it was created. When the current time surpasses that setting the message is expired.
  • dismissable: If set to TRUE (the default is TRUE) the message can be dismissed. If set to FALSE the message will display until it expires by some other means (time or count).
  • dismiss_time: If set to a value greater than 0 (the default is 0) the message will only be suppressed for the number of seconds specified if it is dismissed by a user. After that it will reappear.
  • dismiss_type: This setting determines whether or not the message can be permanently dismissed. Providing the value 0 (the default is 1) will cause the message to not reappear even if a pdm_create_message() call is made to create the same message again. A forthcoming feature is to allow users to see a list of their permanently dismissed messages and restore them.
  • paths: A standard list of paths (just like the blocks page display settings) where you can list a series of paths separated by \n, \r, or \r\n with * as a wildcard. Setting this parameter will cause the PDM to only show on the paths specified.

Example

<?php
  $message
= "My message to the user";
 
$options = array(
   
'type' => 'status',
   
'pdm_type' => 'MyModule Message',
   
'repeat' => FALSE,
   
'persist' => TRUE,
   
'paths' => "user\nuser/*",
  );
 
pdm_create_message($message, $options);
?>

Upcoming Features

  1. Option to save dismissed messages to an archive table.
  2. Option for users to view permanently dismissed messages and clear the suppression of such messages.
  3. Option to view previous messages and filter.

Sponsored by Acquia.

Downloads

Recommended releases

Version Downloads Date Links
7.x-1.0 tar.gz (11.01 KB) | zip (12.08 KB) 2011-Oct-28 Notes

Development releases

Version Downloads Date Links
7.x-1.x-dev tar.gz (11.02 KB) | zip (12.08 KB) 2011-Oct-28 Notes

Project Information


Maintainers for Persistent Dismissable Messages

  • soyarma - 1 commit
    last: 30 weeks ago, first: 30 weeks ago

Issues for Persistent Dismissable Messages

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports