ZD-Mail or ZD-Append, the default response
will be in plain text. If the dispatch method is ZD-Reflect,
however, the default response will be in HTML.
It is possible through the use of the Template (third) field of the
ZD-Method hidden input element to define a template into which
the values of the data input by the user can be substituted and then dispatched.
The Template field allows an author writing a form the ability to
define more precisely how the response should be delivered.
The basic idea is this: You write some text into which you would like the
values of the input entered by the user to be substituted. At each point in
your template where you would like to have a value substituted, place the name
of the input element that the value is associated with, only immediately
preceded by a dollar sign ($) and immediately followed by a
pound sign (#).
When Zot-Dispatch is preparing the response it will parse through your template looking for the points at which the values of the named input elements are substituted.
Example, I have created the following template:
$NAME#,
This is an example of a template being used. ZD substitutes
your entries into the template and returns the response to you.
Your favorite color is: $COLOR#
Your favorite food is: $FOOD#
You drive a $YEAR# $MODEL#.
This concludes this example of a template.
The following form uses this example template. Please
enter the requested information below and press the See Response
button below. Use the "Back" command (if you have one) to return to this
document.
If you tried this form, it should have returned the previously defined
template with your values substituted properly. To better understand exactly
how this form was done, view the source.
Undefined Values
If Zot-Dispatch doesn't receive from the browser a name=value pair whose name
appears within the template and whose value should be substituted into that
template, then Zot-Dispatch will simply strip the dollar ($) and
pound (#) signs from the name of the input element in the template,
leaving the name alone.
This could happen for a number of reasons, one being there is no input element in your form with that name, and another being that no value for that input element was entered. The behavior varies depending on the client being used by the user.
Demonstration:
Pressing the See Response button below will return the same
template as the first example above, only this time no values for the NAME,
COLOR, FOOD, YEAR, and
MODEL elements will be returned. Notice that where previously the value of the
input element was substituted there is now only the name of the input element
that should have been substituted. Use the "back" command to return to this
document if your client has one.
Multiple Values
If two or more input elements are returned having the same name, then only the
last value of that returned element will be substituted into the template.
This feature of Zot-Dispatch makes it possible to have default values for input elements.
Dollar Signs
If you wish to include a dollar sign in your template that is not the beginning
of a reference to a value that is to be substituted, simply place two
consecutive dollar signs in your template.
Example:
I would like to reflect to the user a dollar amount that is entered through a
form. Here is what the template would look like:
<HTML>
<HEAD>
<TITLE>Zot-Dispatch: Dollar Sign Example</TITLE>
</HEAD>
<BODY>
<H1>Dollar Sign Example</H1>
You have entered $$$amount#.
<HR>
<A HREF="http://www.oac.uci.edu/X/W6/zd/2.0/ZD-2.0-Templates.html#dollarex">
Return to the Template Document</A>
</BODY>
</HTML>
The first two of the three consecutive dollar signs above will be replaced by
a single dollar sign while the third dollar sign is for the reference to the
input amount. Try it out below.
Including Special Characters in Templates
If you wish to include HTML in your template (possibly when using ZD-Reflect so
that HTML is returned)
special precautions must be taken if you are
including your template inline. If you are
including your template inline, you
cannot have HTML in your template because it will get mixed up with the HTML
of the document your form is contained within. The soultion to this problem
is quite simple: replace all of the less than signs, greater than signs, and
double quotes with the
Character Entity Set representations of those symbols,
<, > and "
respectively.
If your template is in a separate file that Zot-Dispatch will open or retrieve via HTTP, there is no need to use the character entities.
Example:
To have Zot-Dispatch reflect the following HTML:
<HTML>
<HEAD>
<TITLE>Zot-Dispatch: Embedded HTML Example</TITLE>
</HEAD>
<BODY>
<H1>Embedded HTML Example</H1>
This example showed how to include HTML in an inline template.
<HR>
<A HREF="http://www.oac.uci.edu/X/W6/zd/2.0/ZD-2.0-Templates.html#embedded">
Return to the Template Document</A>
</BODY>
</HTML>
the source for my form would have to look like:
<FORM METHOD=POST ACTION="http://www.oac.uci.edu/cgi-bin/zd-2.0.cgi">
<INPUT TYPE=hidden NAME=ZD-Method VALUE="ZD-Reflect;;body:<HTML>
<HEAD>
<TITLE>Zot-Dispatch: Embedded HTML Example</TITLE>
</HEAD>
<BODY>
<H1>Embedded HTML Example</H1>
This example showed how to include HTML in an inline template.
<HR>
<A HREF="http://www.oac.uci.edu/X/W6/zd/2.0/ZD-2.0-Templates.html#embedded">
Return to the Template Document</A>
</BODY>
</HTML>">
<INPUT TYPE=submit VALUE="Submit Form">
</FORM>
Press the submit button below to see what the result will be:
Subject, From, and Reply-To LinesNote: Reply-To and From support only on version 2.24 and later.
If the first line of any template is of the form
Subject: Subject Information, From: e-mail address(es), or Reply-To:
e-mail address(es), the line will be stripped from your template and the
appropriate e-mail header will be set. If the first line indeed is one of these
three lines, then the second line of the file will be searched to see if it is
another of the three directives.
You can currently have at most two of the three lines present, and only
one of either the Reply-To or From fields.
The information following Subject: on these lines will be used
as the subject line of any e-mail sent by Zot-Dispatch. This information is
discarded if the dispatch method is not ZD-Mail. If this line
is not present, no action will be taken (nothing will be stripped from the
template or ignored).
The information following Reply-To: on these lines will be used
as the Reply-To Line of any e-mail message sent using that template. This
information is discarded if the dispatch method is not ZD-Mail.
If this line is not present, no action will be taken.
The behavior for the From: field is similar to that of the
Reply-To field.
For both the subject line, the from field, and the reply-to field, variable substitution is performed. This means that the e-mail address to which the reply-to field is set can be specified in the form and then substituted.
Example:
Here is a sample ZD-Method input element which has a subject
line specified at the beginning of the template.
<INPUT TYPE=hidden NAME="ZD-Mail;lmegliol@uci.edu;body:Subject:This is the subject of my e-mail message. This is the body of my template.">The e-mail that would be sent by Zot-Dispatch would be "This is the subject of my e-mail message".
lmegliol@uci.edu)