Allow other modules to extend the template and add HTML format option

stella - May 8, 2009 - 13:40
Project:Notify by Views
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Hi,

The attached patch does a few things to help improve the contents of the sent email. First of all, it allows the admin user to configure whether or not the resulting email is sent in plain text or HTML format. It also modifies the template processing slightly.

The most basic improvements are to allow the !uname token to appear anywhere in the template, rather than just in the header. It also allows the user to enter text after the closing !section, so they can add their own footer text if they want.

The final change was to allow other modules to extend the tokens used by invoking a new hook hook_notify_by_views_template_tokens(). For example, another module could define a !date token and set it to the current date. To do that the module would just need to declare a hook implementation like:

function mymodule_notify_by_views_template_tokens($html, $last_mailing) {
  $tokens = array();
  $tokens['!date'] = date("D M j G:i:s T Y");
  return $tokens;
}

The $html variable is provided in case the module wants to add some formatting, and $last_mailing is also provided in case the data returned is time dependent.

Cheers,
Stella

AttachmentSize
notify_by_views_mail_formatting.patch3.77 KB

#1

matt2000 - May 9, 2009 - 07:16

OK, I love all this stuff, but it's too much for one patch...

A few issues:

1.) I really want to upgrade to D6 before doing anything new on 5.x... Can you help there?

2.) I want to use token module instead of the custom token code here... Can you refactor for that as a separate patch?

3.) I want the HTML format handling to be a separate sub-module, packaged with this.

4.) I might even close this project entirely and move all of it into Notify proper. In that case, we should make the notify_mail_send function extensible in itself, so that we dont copy basically the same function in two places.

Thanks for what you've done! Just a little ways to go, and we'll really have this working right!

Best,

Matt

#2

douggreen - June 18, 2009 - 13:51

Matt, We're giving you patches that we needed for our client. but the client won't be upgraded to 6.x until Fall.

#3

matt2000 - June 23, 2009 - 23:40

Thanks, understood & appreciated. :-)

 
 

Drupal is a registered trademark of Dries Buytaert.