How can I get the PHP to display?? Only the HTML will show up in the emails.
Please help! I've been trying to figure it out for weeks!!!!
The field is '1' and the field name is 'show"

<?php
function garland_webform_mail_headers($form_values, $node, $sid, $cid) {
  $headers = array(
    'MIME-Version' => '1.0',
    'Content-Type'  => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
    'X-Mailer'      => 'Drupal Webform (PHP/'. phpversion() .')',
  );
  return $headers;
}
?>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style>

<?php
  // Print out all the Webform fields. This is purposely a theme function call
  // so that you may remove items from the submitted tree if you so choose.
  // unset($form_values['submitted_tree']['element_key']);
  print theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node);
?>

<p class="style1">This is the email from the theme directory.</p>
<table width="462" border="0">
  <tr>
    <td width="127"><span class="style1"><b>Show: </b></span></td>
    <td width="315"><span class="style1">
	  <?php print theme('webform_mail_fields', 0, $form_values['show'], $node); ?></span></td>
  </tr>

</table>
<p class="style1"><?php print t('Submitted on @date', array('@date' => format_date(time(), 'small'))) ?>
  
  <?php print t('The results of this submission may be viewed at:') ?>
  
<?php print url('node/'. $node->nid .'/submission/'. $sid, array('absolute' => TRUE)) ?></p>

Comments

dadderley’s picture

I have modified this one (/modules/webform/templates/webform-mail.tpl.php) and it seems to do what I want.

mlfilms’s picture

I don't have a templates directory in the webform folder under modules. This is the templates directory under the garland theme.
Can you give me the codig you are using>? Is it different then mine?

dadderley’s picture

I am using a dev version (webform-6.x-3.x-dev) where there is a directory called templates.
In webform-6.x-2.6, this directory does not exist the files are on the main level of this directory /sites/all/modules/.

In any case, this is the file to look for (webform-mail.tpl.php)
Copy it into your theme directory and it will control the mail output of your form.
There is some very useful documentation in the file.

mlfilms’s picture

I've tried all sorts off different codes and still nothing. I have modified the webform-mail.tpl.php to be webform-mail-7.tpl.php (7 is the node of the form) in my theme directory and am getting the emails generated from that file. Still nothing. Above is the code in that file.

Do you have a sample code that will show me how to my info up? The themeing text is VERY broad and does not get into specifics...or at least the specifics I understand.

I have date - 1 <-- date is the title of the field and 1 is the field number
show - 2
time (hours, minutes, ampm from the time option within the form) -3
among other fields, but cant get them to display like this.

Date: (Data from form)
Show: (Data from form)
Time: (Data from form)

I would love a sample code with the info above thrown in. It's keeping me from getting lots of other things done! :)
Thanks in advance.

dadderley’s picture

It's keeping me from getting lots of other things done! :)
I know the feeling all too well.

So, you are getting the form to send an email with all of the submitted form data.
But you only want the email to show only a few fields of this data, correct?

What you need to do is to be able to access the individual field data within the arrays

Here is some code that I am using in the webform-confirmation.tpl.php file and you should be able to modify it for use in the webform-mail.tpl.php file:

<?php
// $Id: webform-confirmation.tpl.php,v 1.1 2009/05/22 03:11:18 quicksketch Exp $

/**
 * This is a custom tpl file created by doug. This prepopulates the webform redirect with user submitted values.
 ***** If you change any value here, you need to change all of the files like it "webform-confirmation-111.tpl.php"
 * @file
 * Customize confirmation screen after successful submission.
 *
 * This file may be renamed "webform-confirmation-[nid].tpl.php" to target a
 * specific webform e-mail on your site. Or you can leave it
 * "webform-confirmation.tpl.php" to affect all webform confirmations on your
 * site.
 *
 * Available variables:
 * - $node: The node object for this webform.
 * - $confirmation_message: The confirmation message input by the webform author.
 * - $sid: The unique submission ID of this submission. 
 */
?>

<div class="webform-confirmation"><?php print $confirmation_message ?></div>

<div class="form-results-custom">
 <?php 
$temp_submission = webform_menu_submission_load($sid, $node->nid);
echo "<p>A confirmation has been sent to: " . $temp_submission->data[15]['value'][0]."</p>";
print "<h2>Registrant</h2>";
echo "<ul><li><b>Name</b>: ".$temp_submission->data[1]['value'][0]."&nbsp;" .$temp_submission->data[2]['value'][0]."<br />";
echo "<b>Street</b>: ".$temp_submission->data[3]['value'][0]."<br />";
echo "<b>Province</b>: ".$temp_submission->data[16]['value'][0]."<br />"; 
echo "<b>Postal Code</b>: ".$temp_submission->data[6]['value'][0]."<br />";
echo "<b>Phone</b>: " .$temp_submission->data[7]['value'][0]."</li></ul>";
print "<h2>Registered Riders</h2>";
echo "<ul><li><b>You have registered for this ride:</b> " .$temp_submission->data[20]['value'][0]."<br />";
echo "<b>You have registered:</b> " .$temp_submission->data[11]['value'][0]."<br />";
echo "<b>And you have listed these riders over 16 years old:</b> " .$temp_submission->data[13]['value'][0]."<br />";
echo "<b>You have listed this many riders under 16 years old:</b> " .$temp_submission->data[12]['value'][0]."<br />";
echo "<b>Their names are:</b> " .$temp_submission->data[14]['value'][0]."<br />";
print "<b>You have indicated that you will be sending a cheque to pay for this registration.</b></li></ul>";

?>
<div>

You can find these values :: $temp_submission->data[1] Using the Devel module.

Go to the form in question and go to "Dev Load" (in the admin menu)

Drill down until you get to webform, this will show the number of elements in the array in my case (Array, 18 elements)
Drill further down until you get to components (Array, 22 elements)
Now locate the array for the form element that you need.

now that you know how to reference it, put his value in this sample line:
echo "<p>A confirmation has been sent to: " . $temp_submission->data[15]['value'][0]."</p>";

It is a bit involved, but cool and worth it.

Also you should be using mime mail to send html email. With it you can set up a mail.css file in the theme that is evoked when you send emails.
Take a look http://drupal.org/node/369757#comment-1690912

Hope this helps

mlfilms’s picture

THANK YOU!!!!
It's finally working!!! I got in in a table and I'm getting the results the way I want!!!
I am very grateful...it's only been 4 weeks of banging my head and searching for answers.
Mike

Here is the code for anyone who wants to get results from a form into an email and table.

<?php
// $Id: webform-confirmation.tpl.php,v 1.1 2009/05/22 03:11:18 quicksketch Exp $

/**
* This is a custom tpl file created by Mike with help from Doug. This prepopulates the webform redirect with user submitted values.
***** If you change any value here, you need to change all of the files like it "webform-confirmation-111.tpl.php"
* @file
* Customize confirmation screen after successful submission.
*
* This file may be renamed "webform-confirmation-[nid].tpl.php" to target a
* specific webform e-mail on your site. Or you can leave it
* "webform-confirmation.tpl.php" to affect all webform confirmations on your
* site.
*
* Available variables:
* - $node: The node object for this webform.
* - $confirmation_message: The confirmation message input by the webform author.
* - $sid: The unique submission ID of this submission. 
*/
?>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
-->
</style>


<div class="webform-confirmation"><?php print $confirmation_message ?></div>
<?php 
$temp_submission = webform_menu_submission_load($sid, $node->nid);  
?>


<table width="650" border="0">
  <tr>
    <td width="238"><span class="style3">Date:</span></td>
    <td width="402"><span class="style1"><?php echo " ".$temp_submission->data[3]['value'][0]. "/" .$temp_submission->data[3]['value'][1]. "/" .$temp_submission->data[3]['value'][2]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style1"><strong>Show:</strong></span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[1]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style1"><strong>Time:</strong></span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[15]['value'][0]. ":" .$temp_submission->data[15]['value'][1]. "&nbsp;" .$temp_submission->data[15]['value'][2]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Executive Producer:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[4]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Producer</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[5]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Director:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[6]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Technical Director:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[6]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Assistant Director:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[7]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Audio:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[8]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Overall Comments:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[9]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Producer Comments:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[10]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Director Comments:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[11]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Technical Director Comments:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[12]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td><span class="style3">Off-Air/Equpiment Problems:</span></td>
    <td><span class="style1"><?php echo " ".$temp_submission->data[13]['value'][0]."</p>"; ?></span></td>
  </tr>
</table>

<p class="style1"><?php print t('Submitted on @date', array('@date' => format_date(time(), 'small'))) ?>
  
  <?php print t('The results of this form may be viewed at:') ?>
  
<?php print url('node/'. $node->nid .'/submission/'. $sid, array('absolute' => TRUE)) ?></p>


dadderley’s picture

Dude, I am happy to have helped.

One thing to realize is that all email clients are not the same. Some really suck and only display css formatting in the form of inline styles. This a real pain.

The good news is that drupal 6 version of mime mail does a pretty good job of creating inline styles on the fly.

I created a style sheet called mail.css and put it in the theme that is referenced when the mail is sent. If you have an admin theme that is different than you main theme it may be using that. Make sure that you have added the mail.css to the list of css sheets referenced in your .info file for the theme stylesheets[all][] = mail.css When you do this, mime mail will now reference this style sheet when it sends the emails. It will take the styles from the style sheet and write them into the resulting email as inline styles. This will make sure that your email will look good in just about all email clients.

You will not have to be doing this any more in emails:

<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
-->
</style>

Which probably does not work so good anyway.

mlfilms’s picture

I have it in dreamweaver and I'm making the adjust ments I need in there. I'll be using this same template for a bunch of different forms....which are essentially the same, just dfferent defaults. I'm not too saavy with the css style sheets. I'll have to learn the css way, but I'm still enjoying the high from getting this to work the way I want. :) So far, DW is coing through nicely.

Also, just discovered how to get line break from the submitted form. nl2br () :
Add nl2br after the echo and put the result code in parenthesis

<?php echo nl2br (" ".$temp_submission->data[13]['value'][0]."</p>"); ?>

Here's the updated code for anyone intested in making a form submitted and sent to email appear in a table with line breaks.
Mike

<?php
// $Id: webform-confirmation.tpl.php,v 1.1 2009/05/22 03:11:18 quicksketch Exp $

/**
* This is a custom tpl file created by Mike with help from Doug. This prepopulates the webform redirect with user submitted values.
***** If you change any value here, you need to change all of the files like it "webform-confirmation-111.tpl.php"
* @file
* Customize confirmation screen after successful submission.
*
* This file may be renamed "webform-confirmation-[nid].tpl.php" to target a
* specific webform e-mail on your site. Or you can leave it
* "webform-confirmation.tpl.php" to affect all webform confirmations on your
* site.
*
* Available variables:
* - $node: The node object for this webform.
* - $confirmation_message: The confirmation message input by the webform author.
* - $sid: The unique submission ID of this submission. 
*/
?>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif; color: #003399; }
-->
</style>


<div class="webform-confirmation"><?php print $confirmation_message ?></div>
<?php 
$temp_submission = webform_menu_submission_load($sid, $node->nid);  
?>


<table width="747" border="1" cellpadding="3" cellspacing="7" bordercolor="#CCCCCC">
  <tr>
    <td width="284" align="left" valign="top"><span class="style3">Date:</span></td>
    <td width="447" align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[3]['value'][0]. "/" .$temp_submission->data[3]['value'][1]. "/" .$temp_submission->data[3]['value'][2]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style1"><strong>Show:</strong></span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[1]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style1"><strong>Time:</strong></span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[15]['value'][0]. ":" .$temp_submission->data[15]['value'][1]. "&nbsp;" .$temp_submission->data[15]['value'][2]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Executive Producer:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[4]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Producer</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[5]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Director:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[6]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Technical Director:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[7]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Assistant Director:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[8]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Audio:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo " ".$temp_submission->data[9]['value'][0]."</p>"; ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Overall Comments:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo nl2br (" ".$temp_submission->data[10]['value'][0]."</p>"); ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Producer Comments:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo nl2br (" ".$temp_submission->data[11]['value'][0]."</p>"); ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Director Comments:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo nl2br (" ".$temp_submission->data[12]['value'][0]."</p>"); ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Technical Director Comments:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo nl2br (" ".$temp_submission->data[13]['value'][0]."</p>"); ?></span></td>
  </tr>
  <tr>
    <td align="left" valign="top"><span class="style3">Off-Air/Equpiment Problems:</span></td>
    <td align="left" valign="top"><span class="style5"><?php echo nl2br (" ".$temp_submission->data[14]['value'][0]."</p>"); ?></span></td>
  </tr>
</table>

<p class="style1"><?php print t('Submitted on @date', array('@date' => format_date(time(), 'small'))) ?>
  
  <?php print t('The results of this submission may be viewed at:') ?>
  
<?php print url('node/'. $node->nid .'/submission/'. $sid, array('absolute' => TRUE)) ?></p>



Zoologico’s picture

Wow I am so close:

1) I created a webform-mail-[nid].tpl.php.
2) I modified it with the right variables and they all print where I want them to print including the line break using the nl2br PHP function
3) I am using MIME mail
4) I created a mail.css and copied the style stuff to it and put it in my admin theme which is also my default theme and linked to it from the tpl file
5) I added this line to the theme .info page per http://drupal.org/node/369757#comment-1690912

stylesheets[print][] = mail.css

I can't seem to get my fonts to look the way they do in Dreamweaver. My style sheet reads: .style6 {font-family: Georgia, "Times New Roman", Times, serif}, yet I see only arial all over the email.

What am I missing?