/[drupal]/contributions/modules/webform/THEMING.txt
ViewVC logotype

Contents of /contributions/modules/webform/THEMING.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download)
Thu May 7 22:38:13 2009 UTC (6 months, 2 weeks ago) by quicksketch
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +58 -98 lines
File MIME type: text/plain
Updating HEAD with 2.x branch for new 3.x version.
1 Overview
2 --------
3 Webform supports theming similar to the CCK or Views modules. Any webform
4 may be themed on the server side, though doing so may require a reasonable
5 amount of knowledge about the Drupal Forms API. More information about the Forms
6 API may be found at http://api.drupal.org/api/file/developer/topics/forms_api.html
7
8 Theme submission e-mails
9 -----------------------
10 The default e-mails sent by webform are fairly basic. If you like, you may
11 customize the display of e-mails sent by each individual webform.
12
13 - Open the Webform module directory.
14
15 - Copy (do not move!) the "webform-mail.tpl.php" file to your theme directory.
16
17 - Open up the new file and edit it to your liking. The webform-mail.tpl.php file
18 contains further instructions on how to get started with theming the e-mail.
19
20 - If you want to edit the e-mail sent by only one particular webform, rename the
21 file "webform-mail-[node id here].tpl.php", replacing [node id here] with the
22 node ID of the webform.
23
24 - Clear the theme cache! Visit admin/settings/performance and click the
25 "Clear cached data" button at the bottom of the page. You may also find
26 using devel module will speed up this process a bit. This needs to be done
27 every time you create or rename a .tpl.php file, but isn't necessary once
28 these files already exist.
29
30 - To get a better idea of what variables are available to you, you can include
31 the print_r function in your email. Simply include the line:
32
33 <?php print_r($form_values) ?>
34
35 to get a listing of all the available fields you can use in your mail.
36
37 - Important Note for Webform Themers: When webform added support for fieldsets
38 (i.e. nested fields), it became necessary to increase the complexity of themed
39 e-mails. Previously, the $form_values variable only sent the values of the
40 form in a flat array. Now, $form_values contains two arrays of information:
41
42 $form_values['submitted'] => An array of fields and their submitted values (identical to the previous value of $form_values)
43 $form_values['submitted_tree'] => An array of fields and their values structured in a recursive array
44
45 - Advanced Webform e-mail Theming: Theming the e-mail headers may also be done
46 by overriding the theme_webform_mail_headers() function from webform.module.
47 Just copy the code out of webform.module and change as necessary in your
48 template.php file. This allows you to customize the e-mail headers.
49
50 Theme the confirmation page
51 ---------------------------
52
53 After a user submits a webform, they are directed to a page that contains the
54 confirmation message set in the webform node settings (assuming the form doesn't
55 direct to a complete URL). These instructions let you customize the format of
56 the confirmation page of a single node or all webforms on your site.
57
58 - Open the Webform module directory.
59
60 - Copy (do not move!) the "webform-confirmation.tpl.php" file to your theme
61 directory.
62
63 - Open the new file and change it's contents to the your liking. Here's an
64 example that inserts some additional HTML around the confirmation message and
65 gives links to edit the submission.
66
67 <?php /* Begin sample webform confirmation page */ ?>
68
69 <div class="confirmation-message">
70 <?php print $confirmation_message ?>
71 </div>
72
73 <ul>
74 <li><a href="<?php print url('node/'. $node->nid . '/submission/'. $sid)?>">View your submission</a></li>
75 <li><a href="<?php print url('node/'. $node->nid . '/submission/'. $sid .'/edit')?>">Edit your submission</a></li>
76 </ul>
77
78 <?php /* End sample webform confirmation page */ ?>
79
80 - You may edit the webform-confirmation.tpl.php file in your theme directory,
81 this will affect all the webform mails sent by your entire site. Or, if you
82 want to edit the e-mail sent by only one particular webform, rename the file
83 "webform-confirmation-[node id here].tpl.php", replacing [node id here] with
84 the node ID of the webform.
85
86 - Visit admin/settings/performance and click the "Clear cached data" button.
87
88 Theme display of an entire webform
89 ----------------------------------
90
91 Theming a webform can be useful for rearranging elements or customizing the
92 appearance of multiple components at once. This tutorial assumes usage
93 of the phptemplate engine.
94
95 - Copy the "webform-form.tpl.php" file from the webform directory to your
96 theme directory. You may rename this file
97 "webform-form-[node id here].tpl.php" if you want to theme one particular
98 webform on your site. Replace [node id here] with the node ID of the webform.
99
100 - Open up your new file and customize the webform however you like.
101
102 - Visit admin/settings/performance and click the "Clear cached data" button.
103
104 - All Webform forms have 2 main fieldsets: "submitted", and "details". Although
105 you may move things around as you wish, keep all your components within the
106 "submitted" fieldset. Only the "submitted" fieldset is displayed and Webform
107 depends on the other two to operate properly, so don't mess with them unless
108 you have good reason to do so (like you're forwarding your webform to a custom
109 PHP or PERL script).
110
111 $Id: THEMING.txt,v 1.10.2.3 2008/09/06 06:07:56 quicksketch Exp $

  ViewVC Help
Powered by ViewVC 1.1.2