Theming Privatemsg New Message Indication Block

Last updated on
30 April 2025

Sometimes the default messages outputted by Drupal or the contrib modules aren't always what we want and therefore we are tempted to make the necessary changes to suit our needs. This little article is a nice way to override the default new message indication block to something more of your choice. By default, when a user receives a new message, it reads "You have a new message, click here to read it" and if there are multiple messages "You have @count new messages, click here to read them". But let's say I want to make it simpler. The snippet below will show you how its done.

function theme_privatemsg_new_block($count) {
  $text = format_plural($count, 'You have a new message, click here to read it',
                        'You have @count new messages, click here to read them',
                        array('@count' => $count));

  return l($text, 'messages', array('attributes' => array('id' => 'privatemsg-new-link')));
}

Copy the above snippet to your theme's template.tpl.php file and paste it anywhere of your choice (easiest place is at the bottom) and replace the theme_privatemsg_ to the name of yourthemename_privatemsg_ and replace the $count and the @count values to the words of your choice and clear your theme's cache after uploading to your theme's directory. Thanks to Berdir for his support in helping me to get this to work.

Help improve this page

Page status: Not set

You can: