Please reports bugs and problems with this plugin in this forum thread.
This plugin requires a separate language plugin called zem_contact_lang
to be installed and activated to work properly.
<label>
, <legend>
and <fieldset>
tags.pap_contact_cleaner
plugin).The simplest form is shown below, which produces a default form with Name, Email and Message fields. Email will be delivered to recipient@example.com, with the user’s supplied email as the “From:” address.
<txp:zem_contact to="recipient@example.com" />
To specify fields explicitly, use something like this:
<txp:zem_contact to="recipient@example.com">
<txp:zem_contact_email />
<txp:zem_contact_text label="Phone" min=7 max=15/>
<txp:zem_contact_textarea label="Your question" />
<txp:zem_contact_submit label="Send" />
</txp:zem_contact>
Alternatively, place the field specifications in a Textpattern form, and call it like this:
<txp:zem_contact to="recipient@example.com" form="mycontactform" />
zem_contact
, to create form that is initially hidden by setting the send_article
attribute.zem_contact_send_article
, to create a ‘send article’ link which reveals the aforementioned form when clicked.<txp:zem_contact send_article="1" />
<txp:zem_contact_send_article />
By default the form contains fields for your name and email address, the recipient’s email address and a personal message, but similar to contact forms you can create your own form layout. Some things you need to know:
send_article
attribute to 1
in the zem_contact
tag.zem_contact_email
tag with the send_article
attribute set to 1
. This field will be used as the recipient email address.<txp:zem_contact to="you@example.com" send_article="1">
<txp:zem_contact_email label="Recipient Email" send_article="1" />
<txp:zem_contact_email label="Your Email" />
<txp:zem_contact_submit label="Send Article" />
</txp:zem_contact>
<txp:zem_contact_send_article />
<txp:zem_contact />
produces a flexible, customisable email contact form. It is intended for use as an enquiry form for commercial and private sites, and includes several features to help reduce common problems with such forms (invalid email addresses, missing information).
<txp:zem_contact_send_article />
can be used to create a “send article” link within an article form, connecting it to the contact form.
All other tags provided by this plugin can only be used inside a <txp:zem_contact>
… </txp:zem_contact>
container tag or in a Textpattern form used as the form
attribute in the <txp:zem_contact />
tag.
<txp:zem_contact />
May be used as a self-closing or container tag. Place this where you want the input form to go. Status and error messages, if any, will be displayed before the form.
to="email address"
requiredto_form="form name"
from="email address"
from_form="form name"
subject="subject text"
subject_form="form name"
thanks="text"
thanks_form="form name"
redirect="URL"
label="text"
send_article="boolean"
copysender="boolean"
form="form name"
show_input="boolean"
show_error="boolean"
See Getting started and Advanced examples.
<txp:zem_contact_text />
Creates a text input field and corresponding <label>
tag. The input value will be included in the email, preceded by the label.
label="text"
name="value"
break="tag"
<br />
. Use break=""
to put the label and input field on the same line.default="value"
min="integer"
max="integer"
size="integer"
required="boolean"
<txp:zem_contact_text label="Your name" />
<txp:zem_contact_email />
Input field for user’s email address.
The entered email address will automatically be validated to make sure it is of the form “abc@xxx.yyy[.zzz]”. On non-Windows servers, a test will be done to verify that an A or MX record exists for the domain. Neither test prevents spam, but it does help detecting accidental typing errors.
label="text"
name="value"
break="tag"
<br />
. Use break=""
to put the label and input field on the same line.default="value"
min="integer"
max="integer"
size="integer"
required="boolean"
send_article="boolean"
<txp:zem_contact_email label="Your email address" />
<txp:zem_contact_textarea />
Creates a textarea.
label="text"
name="value"
break="tag"
<br />
. Use break=""
to put the label and input field on the same line.default="value"
cols="integer"
rows="integer"
min="integer"
max="integer"
required="boolean"
Textarea that is 40 chars wide, 10 lines high, with a customized label:
<txp:zem_contact_textarea cols="40" rows="10" label="Your question" />
<txp:zem_contact_submit />
Creates a submit button.
When used as a container tag, a “button” element will be used instead of an “input” element.
label="text"
button="boolean"
Standard submit button:
<txp:zem_contact_submit />
Submit button with your own text:
<txp:zem_contact_submit label="Send" />
Usage as a container tag, which allows you to use Textpattern tags and HTML markup in the submit button:
<txp:zem_contact_submit><strong>Send</strong> question</txp:zem_contact_submit>
<txp:zem_contact_submit><img src="path/to/img.png" alt="submit"></txp:zem_contact_submit>
<txp:zem_contact_select />
Creates a drop-down selection list.
list="comma-separated values"
requiredselected="value"
label="text"
name="value"
break="tag"
<br />
. Use break=""
to put the label and input field on the same line.delimiter="character"
required="boolean"
Select list labeled ‘Department’, containing three options and a blank option (due to the comma before ‘Marketing’) shown by default, forcing the user to make a selection.
<txp:zem_contact_select label="Department" list=",Marketing,Sales,Support" />
Select list containing three options with ‘Marketing’ selected by default.
<txp:zem_contact_select list="Marketing,Sales,Support" selected="Marketing" />
<txp:zem_contact_checkbox />
Creates a check box.
label="text"
name="value"
break="tag"
<br />
. Use break=""
to put the label and input field on the same line.checked="boolean"
required="boolean"
Shrink-wrap agreement which must be checked by the user before the email will be sent.
<txp:zem_contact_checkbox label="I accept the terms and conditions" />
Optional checkboxes:
Select which operating systems are you familiar with:<br />
<txp:zem_contact_checkbox label="Windows" required="0" /><br />
<txp:zem_contact_checkbox label="Unix/Linux/BSD" required="0" /><br />
<txp:zem_contact_checkbox label="MacOS" required="0" /><br />
<txp:zem_contact_radio />
Creates a radio button.
group="text"
requiredlabel="text"
requiredname="value"
group
attribute.break="tag"
checked="boolean"
Group mutually exclusive radio buttons by setting the group
attribute on the first radio button in a group. Only the chosen radio button from each group will be used in the email message. The message will be output in the form group: label for each of the chosen radio buttons.
<txp:zem_contact_radio label="Medium" group="I like my steak" />
<txp:zem_contact_radio label="Rare" />
<txp:zem_contact_radio label="Well done" />
<txp:zem_contact_radio label="Wine" group="With a glass of" />
<txp:zem_contact_radio label="Beer" />
<txp:zem_contact_radio label="Water" />
<txp:zem_contact_secret />
This tag has no effect on the form or HTML output, but will include additional information in the email. It can be used as a self-closing tag or as a container tag.
name="text"
label="text"
value="value"
Usage as a self-closing tag
<txp:zem_contact_secret value="The answer is 42" />
Usage as a container tag
<txp:zem_contact_secret label="Dear user">
Please provide a useful example for this tag!
</txp:zem_contact_secret>
<txp:zem_contact_serverinfo />
This tag has no effect on the form or HTML output, but will include additional information in the email based on the PHP $_SERVER variable.
name="value"
requiredlabel="text"
Add the IP address of the visitor to the email
<txp:zem_contact_serverinfo name="REMOTE_ADDR" label="IP number" />
Add the name of the visitor’s browser to the email
<txp:zem_contact_serverinfo name="HTTP_USER_AGENT" label="Browser" />
<txp:zem_contact_send_article />
Use this tag in your individual article form, where you want the “send article” link to be displayed.
linktext="text"
See Getting started
Using show_input
and show_error
to display the form and error messages on different parts of a page. A form is used to make sure the contents of both forms are identical, otherwise they would be seen as two independent forms. The first form only shows errors (no input), the second form only shows the input fields (no errors).
<div id="error">
<txp:zem_contact form="contact_form" show_input="0" />
</div>
<div id="inputform">
<txp:zem_contact form="contact_form" show_error="0" />
</div>
Apart from the show_error
and show_input
attributes, all other attributes must be 100% identical in both forms, otherwise they would be seen as two unrelated forms.
Specify the subject_form
attribute and create a form which includes a zem_contact_select
tag:
<txp:zem_contact to="you@example.com" subject_form="my_subject_form" />
<txp:zem_contact_text label="Name" /><br />
<txp:zem_contact_email /><br />
<txp:zem_contact_select label="Choose Subject" list=",Question,Feedback" /><br />
<txp:zem_contact_textarea label="Message" /><br />
</txp:zem_contact>
Create a Textpattern form called “my_subject_form”, containing:
<txp:php>
global $zem_contact_form;
echo $zem_contact_form['Choose Subject'];
</txp:php>
The label
used in the zem_contact_select
tag must be identical to the corresponding variable in the subject_form
. Here we used Choose subject
.
If you’d prefer to add a common prefix for all subjects, use a subject_form
containing:
<txp:php>
global $zem_contact_form;
echo 'My common prefix - ' . $zem_contact_form['Choose Subject'];
</txp:php>
Specify the to_form
attribute and create a form which includes a zem_contact_select
tag:
<txp:zem_contact to_form="my_zem_contact_to_form">
<txp:zem_contact_text label="Name" /><br />
<txp:zem_contact_email /><br />
<txp:zem_contact_select label="Department" list=",Support,Sales" /><br />
<txp:zem_contact_textarea label="Message" /><br />
</txp:zem_contact>
Create a Textpattern form called “my_zem_contact_to_form”, containing:
<txp:php>
global $zem_contact_form;
switch($zem_contact_form['Department'])
{
case 'Support':
echo 'crew@example.com';
break;
case 'Sales':
echo 'showmethemoney@example.com';
break;
default:
echo 'someone@example.com';
}
</txp:php>
The label
used in the zem_contact_select
tag must be identical to the corresponsing variable in the to_form
. Here we used Department
.
A ‘default’ email address in the to_form
is specified to ensure that a valid email address is used in cases where you add or change a select/radio option and forget to update the to_form
.
Never use tags like zem_contact_text
, zem_contact_email
or zem_contact_textarea
for setting the recipient address, otherwise your form can be abused to send spam to any email address!
The form itself has a class zemContactForm set on the FORM
HTML tag.
The list of error messages (if any) has a class zemError set on the UL
HTML tag that encloses the list of errors.
name
attribute of the corresponding tag. When styling forms based on this class, you should explicitly set the name
attribute because automatically generated names may change in newer zem_contact_reborn versions.Only the changes that may affect people who upgrade are detailed below.
To save space, links to forum topics that detail all the changes in each version have been added.
The plugin API of zem contact, developed by Tranquillo, is similar to the comments API of Textpattern, which is explained in the Textbook Plugin Development Topics and Combat Comment Spam.
Two callback events exist in zem_contact_reborn:zemcontact.submit
is called after the form is submitted and the values are checked if empty or valid email addresses, but before the mail is sent.zemcontact.form
let’s you insert content in the contact form as displayed to the visitor.For reference here are the commands that will be interesting to plugin developers:
// This will call your function before the form is submitted
// So you can analyse the submitted data
register_callback('abc_myfunction','zemcontact.submit');
// This will call your function and add the output (use return $mystuff)
// to the contact-form.
register_callback('abc_myotherfunction2','zemcontact.form');
// To get hold of the form-variables you can use
global zem_contact_form;
// With the following two lines you can tell zem_contact if your
// plugin found spam
$evaluator =& get_zemcontact_evaluator();
// The passed value must be non-zero to mark the content as spam.
// Value must be a number between 0 and 1.
$evaluator -> add_zemcontact_status(1);
Multiple plugins can be active at the same time and each of them can mark the submitted content as spam and prevent the form from being submitted.
An example of a plug-in connecting to Zem Contact Reborn’s API:
register_callback('pap_zemcontact_form','zemcontact.form');
register_callback('pap_zemcontact_submit','zemcontact.submit');
function pap_zemcontact_form() {
$field = '<div style="display:none">'.
finput('text','phone',ps('phone'),'','','','','','phone').'<br />'.
finput('text','mail',ps('mail'),'','','','','','mail').'</div>';
return $field;</code>
}
function pap_zemcontact_submit() {
$checking_mail_field = trim(ps('mail'));
$checking_phone_field = trim(ps('phone'));
$evaluation =& get_zemcontact_evaluator();
// If the hidden fields are filled out, the contact form won't be submitted!
if ($checking_mail_field != '' or $checking_phone_field != '') {
$evaluation -> add_zemcontact_status(1);
}
return;
}