HowTo: Theme messages menu

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

With the help of Berdir I was able to overwrite the output of the messages menu without losing the dynamic output of new messages.

What I did, was create my own custom module ( name module = MYMODULE ) where I added the following code.

// Privatemsg menu override
function MYMODULE_menu_alter(&$items) {
  // Replace privatemsg_title_callback
  $items['messages']['title callback'] = 'MYMODULE_title_callback';
}


function MYMODULE_title_callback() {

  global $user;

  if ($user) {
    $count = privatemsg_unread_count($user);
  }
  else {
    $count = privatemsg_unread_count();
  }

  if ($count > 0) {
    return t('Inbox (' . $count . ')');
  }
  return t('Inbox');
}

Initial issue can be found here: http://drupal.org/node/1071734

Help improve this page

Page status: Not set

You can: