Is there any easy way I can theme the webform-mail.tpl.php so it sends different emails to submitter and "E-mail to addresses" in the webform settings?

Comments

quicksketch’s picture

Yes, read the documentation at the top of the webform-mail.tpl.php file. You can switch e-mails based on the $cid variable. The "E-mail to address" will have the $cid of 0.

tsvenson’s picture

Thanks for your reply, but when I did a print on $cid it came out as "default" for the E-mail to address and 2 for the submitter...

quicksketch’s picture

Oh, shoot. Thanks. I thought it was "0", but "default" sounds correct. Just do IF statements based on $cid == 'default' to send different information to the separate e-mail addresses.

tsvenson’s picture

Oki, should be no problem. As I got 2 for the submitter, can there be more values as well or can I assume that 2 is always used for the submitter?

quicksketch’s picture

'2' is the Component ID for your webform's "email" component. If you set up multiple email components, each one would have a unique internal ID (the $cid). That way you could theme e-mails differently if one e-mail was for "Your e-mail" and another one was for "Your friend's e-mail" or something similar. The $cid will vary depending on what internal identifier each field was assigned upon creation.

tsvenson’s picture

Thanks quicksketch, worked perfect.

I think it would be useful if you add the the header that to be able to insert line breaks they should be done so using "\r\n" for text emails and "<br>" for html emails in print strings.

dflitner’s picture

Is it possible to do something like if ($cid == email): ?

Our site uses a lot of webforms, and I was hoping to be able to send a generic confirmation email to the submitter that says "Thanks for submitting". However, I didn't want to make a webform-mail-nid.tpl file for each and every webform.

The email fields in most of the webforms are in a different location in the form, so each cid is a different number, I think. Is it possible to pull out the submitted email and use it in the cid if statement? Or is there another way to get a similar result?

I tried $form_values['submitted_tree']['email'] but it doesn't work. And printing that field just gives blank space.

Thanks for any suggestions.

quicksketch’s picture

Status: Active » Closed (fixed)

Is it possible to do something like if ($cid == email): ?

Generally no. You can loop through all the node components and find which ones are of type e-mail, then do some action on it. Since this issue was opened support for custom theming is no longer provided in the Webform issue queue, so I'm closing this.