I have installed Privatemsg, and I need to output the "My messages (x)" link programmatically in block.tpl.php.

I tried the following code, but it only prints "My Messages", when I need a counter for the new messages:

print l('My messages', 'messages');

You can use the function privatemsg_title_callback() like this:

print l(privatemsg_title_callback(), 'messages');

And as marcvangend mentioned, Privatemsg already provides a block that informs the user if he has new messages and a block that contains exactly such a link and additionally a link to write a new private message. Why not use one of these instead?

  • I've created individual block for users, to edit their profiles, content etc. I mean, i manually added such links: <?php print l('add blog entry', 'node/add/blog'); ...and so on ?> So i needed to manually create a link to "my messages (x)" – Alexander Kim Jun 1 '11 at 16:00

The module already contains a block that does something similar: "New message indication". You can use that block and alter the output if needed by overriding the theme_privatemsg_new_block() function.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.