format node body per user

Dave Cohen - September 12, 2005 - 22:57
Project:Mail
Version:4.6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I have a node type I'd like to send out via email, but I theme the node in a way that varies depending on the user viewing it. So I needed a way to theme the mail message depending on who is receiving it. Attached is a patch that works for me so far.

The main change is this: instead of relying on node_view() to get the message body, I call a new hook, hook_view_mail(). If not found, the behavior defaults to the original (node_view()). If hook_view_mail() is implemented, it is passed the node, account of the recipient, and the mail format.

I've made a couple changes which were not necessary for this feature, but make the mail module work better for me. In particular theme_mail_message() now also takes the recipient account, and I moved the logic of plain vs html from _mail_dispatch() into theme_mail_message().

This patch addresses http://drupal.org/node/25502 and http://drupal.org/node/15901 as well. (Sorry to include so much in a single patch).

I think it would be great if these changes made it into the module, but if not I just want to share what works for me. Thanks for a great module.

AttachmentSize
mail_0.patch4.84 KB

#1

Dave Cohen - September 13, 2005 - 21:30
Status:active» needs review

Just changing status to reflect that there is a patch.

 
 

Drupal is a registered trademark of Dries Buytaert.