Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While searching for mail formating I found alot of questions directed to readme.txt - While the documentation there is quite good I think it could be improved alot via providing theme snippets for all the common tasks and an example template file. "Copy and paste coding" is probably not optimal but it helps getting people quickstarted and reduces redundant questions in the issue quere.
If anyone who has finished an email template stumbles across this issue would copy, generalize and comment some of his code we might be able to get such a list together quickly.
Comments
Comment #1
mlaw CreditAttribution: mlaw commentedHere's my template for one of my Webform emails. It's pretty straight forward.
Comment #2
jadowd CreditAttribution: jadowd commentedWhere do you put this code? I have several forms that I need to optimize the email output for.
Thanks,
Comment #3
s.Daniel CreditAttribution: s.Daniel commentedThis goes in files in your theme like webform-mail-4769.tpl.php - more information is available in the THEMING.txt supplied with the module.
Thanks alot mlaw for providing this example it will help alot of people. I have just checked my template file but what you have provided is by far more suitable as an example.
Comment #4
jadowd CreditAttribution: jadowd commentedThanks Guys, this has been a great help and an awesome learning experience.
Regards!
Comment #5
xalexas CreditAttribution: xalexas commentedThanks a million for this! I was searching everywhere for this explanation.
THEMING.txt was not very helpful. Consider that everyone doesn't know Drupal in depth. Please write some code for beginners like this one in THEMING.txt.
Simplest form of displaying submited field value for me is something like this:
Maybe this one is better but I don't know how to dynamically print field labels. If anyone know how to print labels please post here.
Comment #6
mlaw CreditAttribution: mlaw commentedGlad my theme up top has been helping. Perhaps somebody can help me with a new situation I'm facing:
I have a select component that has a key-value pair of: 45|Canada Express Shipping - $45
I'm trying to only call the value 'Canada Express Shipping - $45' in my Webform theme email using this code:
However, it only pulls the key which is '45'. How do I only pull the value 'Canada Express Shipping - $45' into my webform themed email?
Thanks
Comment #7
quicksketchIn 3.x you would simply use the token %email[shipping]. In 2.x, it gets sticky because you have to pull the component out of $node->webform['components'], then parse the list of options and match "45" to the option.
Comment #8
mlaw CreditAttribution: mlaw commentedThanks, quicksketch. I'll settle for another option and wait for this functionality in 3.x. :)
Comment #9
quicksketchThis is of much less importance now that the 3.x version has a built-in templating system for e-mails.
Comment #10
mlaw CreditAttribution: mlaw commentedThat's great to know. I've been wanting something like that for a long time.
Perhaps this is the wrong place to post this question but I'll ask anyways: if I upgrade to Webform 3.x, will all my 2.x Webforms be intact and work correctly?