UPDATE: (April 3, 2016) Many of the recent patches have been rolled into the dev release. It should be significantly more stable than 1.1 has been. I will be putting this updated version to use myself on a few sites to ensure it works as expected.

Big thanks to erikhopp and many others who stepped in and provided patches to shore up the module.


 

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.
  • disable_ajax: Restrict this pdm from being displayed inside of a modal, or content powered by an AJAX callback.
  • uid: The user that this message should be shown to, defaults to the logged in user.

Example

  $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 for users to view permanently dismissed messages and clear the suppression of such messages.
  2. Option to view previous messages and filter.

Sponsored by Acquia and Blue Coda.

Project information

Releases