Wow, it seems that Drupal's Webform module has come a long way since I last used it (which I believe was Drupal 5.x). It's so convenient and really latches onto the new template hints and stuff from Drupal 6 (here I am talking about it while Webchick announced yesterday the D7 criticals queue is under 200, w00t!).
We had a use case where we wanted to send an email from our web site--on behalf of someone--to someone else. You've seen these around in the political world, "send a note to Congressman blah blah and tell him to STOP lobbying for the use of plutonium as a dietary supplement!" We're hosting a site for a cause, but we're trying to facilitate our constituency sending an email to someone else.
Turns out webform handles this quite well. You fill out a form, and you can specify who to send mails to. We've set the main "send a copy to" to the site administrator, who wants a copy of all mails. We've then set to webform components for the two other emails. One of the components is the sender's email, and another is a hidden webform field which contains the recipient's email.
All the pieces were coming together nicely, except the email coming out was pretty default. I started digging for themeable emails, and turns out, it was already hooked in. Genius. Not JUST that, but with a template hint for the node id, you can even theme the emails just for a particular webform, so you don't have to trash all webforms.
I took webform-mail.tpl.php and copied it into my theme folder, then copied that over to webform-mail-116.tpl.php (as my node ID for this webform was 116). I could then remove the default theme calls, and print out a templated message just containing the barebones information so it looks just like a regular email.
This whole process took me 20 minutes... bonzer!
Post new comment