By aiphes on
Hi
i would to theme the webform-mail.tpl...so i copy it in my theme, but how to insert html code into php ? and how to know the value name detail ? is it the name displayed in editing/creation of component ??
here i am actually :
<?php print_r($submission) ?>
<?php print "<div id='corps-email'>"//debut div corps du mail?>
<?php print t('Submitted values are') ?>:
%email_values
<?php print "</div>"//fin corps du mail?>
<?php //print t('The results of this submission may be viewed at:') ?>
%submission_url
but print-r doesnt work, and the other part of code doesnt appear in the source code of my email..
thanks for helping
Comments
so i've changed my code but
so i've changed my code but still no result in email received instead of the source.
EDIT: is there need to setup something for html email format ? because in thunderbird the html doesnt appear in source code..i've setup html format for all webform forms in general settings of webform...i dont know what to do more...help
Dev Server Shared Hosting
8 websites powered by drupal 6,8 & 9 - Hosted by Always Data
so the tpl.php doesnt work
so the tpl.php doesnt work for me; i put the code at the bottom of the page webform/email...but i dont know how to do to get the label in black and the answer in single text...because
- %email[2] give me the ask and the answer..
- %value[2] give me the answer..
Dev Server Shared Hosting
8 websites powered by drupal 6,8 & 9 - Hosted by Always Data
nobody knows how to separate
nobody knows how to separate question and the answer ( key and value) ?? its the final problem that i ve...please some help
Dev Server Shared Hosting
8 websites powered by drupal 6,8 & 9 - Hosted by Always Data
Process for theming email
Hi aiphes
Here's a rough idea of what you should do. When I've got some more time I'll try to turn this into a Documentation page with some more examples of cool stuff you can do with Webform emails.
Preliminaries
Webforms should now be set up to send HTML emails, but you'll want to edit the template file to make it do interesting things.
Template Setup
E.g. webform-mail-6.tpl.php for the webform with node id 6.
Template Content
A few notes on what you'll see in the original tpl file:
print ($email['html'] ? '<p>' : '')%submission_urlif($submission)before you do anything special. This tests if the webform has got any submitted content. Otherwise you'll get an error because $submission is empty on the Webform "Edit e-mail settings" page. You'll also prevent unnecessary calculations and formatting from being done that won't be displayed on that page.Example
Looping through all the fields and outputting in a table
thanks a lot ! great
thanks a lot ! great explanation...when i go to theme a new webform mail it will be useful :)
i use mimemail actually and its a better way to read email...so after that i'll try your way
Dev Server Shared Hosting
8 websites powered by drupal 6,8 & 9 - Hosted by Always Data
Ok, but what should I do with
Ok, but what should I do with file fields? And another thing, I have list of countrys like:
PL|Poland
UK|England
US|United States
when I use something like this:
Im getting only key name not regular name.
print_r() is your friend
Hi rolkos
Do a print_r of $node and $submission and paste the output here (you may trim everything not related to the file field and the country list field). I haven't used either of those so I'll have to see the data structure to help you.
File Field
In my example I used
if($entry['type']=='fieldset'){to test for a fieldset, so you could just add an else if and check for a filefield (or turn it into a switch if you're going to check lots of other fields). I'm not sure what the filefield's type is named, however. You should be able to find that in the print_r. To print a link to the file you would use$filefield_name is a human readable name if that exists (I don't think so?), otherwise use "Download File" or something else in the print_r.
$filefield_url is the url you'll get in the print_r.
List Values
The key name is returned in the $submission variable so you'll have to look up the actual name in the $node variable. Make another else-if, like above, but since you'll be looking up a value of a specific field you need to put another if in there to test whether it's the correct field (using the $eid variable in my example), e.g.
Just to add to malberts'
Just to add to malberts' post, I had to deal with this same problem and this is how I solved it though I am curious if there's a more efficient solution. I'm no PHP expert so it wouldn't surprise me if there were a better way.
Since select fields use a \r for a row delimiter and a pipe for a column delimiter, I split the string into an array, then cycled the array looking for a match:
Hope this helps someone save some time!
Wow, thanks a ton for this,
Wow, thanks a ton for this, it definitely saved me some time.
One thing I had to do differently was on lines 3-5 of your code:
Instead, I had to split along \n, not \r, so it was:
Otherwise, worked like a charm. Thanks.