Skip to content
GetSimpleCMS-CE edited this page Jan 3, 2025 · 2 revisions

Welcome to the plugin-p01-contact wiki!

Installation

Download or clone the repository, then place the p01-contact/ directory and the file p01-contact_gs.php in plugins/.

Usage in pages

Just write tags in your pages according to the syntax.

This is a default contact form :
    
(% contact %)
    
Simple.

Reminds you to fill the Meta Description accessible in page options. If you don't, GetSimple will show the tag source in the source code of the output page.

Usage in themes and templates

You can use it in components, themes or templates by manipulating the variable $p01contact, already initialized. For example, to add a default contact form in your sidebar :

<?php
get_component('sidebar');
echo $p01contact->parse('(% contact %)');
?>

Configuration

The plugin settings are accessible in the GetSimple administration.

Debug

When Debug is enabled in the plugin settings, a debug report is shown before the pages.

The settings are stored in a config.json file. This file shouldn't be edited manually, as a functional configuration panel can be displayed using :

echo $p01contact->panel();

This panel is accessible in the supported CMS, see GetSimple plugin#configuration or Pico CMS plugin#configuration.

General configuration

Setting Description
Default emails One ore more email addresses, separated by commas, that will receive mails from every forms.
Language Define the global language used in forms. See translation.
Messages minimum length Minimum number of characters to write in message fields to be valid.
Default parameters Parameters used for default forms. See syntax.
Separator Character separating parameters in the syntax. Comma by default. You may want to use a less-common character if you need commas inside the parameters.
Logs number Maximum number of entries to keep on logs.

Default language and form language

The default global language is English, or may be set trough code.
When used as a CMS plugin, the global default language will match the system one.

Each form can override this setting and be defined to a specific language.

$p01contact = new P01contact();
$p01contact->default_lang = 'ru';

$form = new P01contactForm($p01contact);
$form->lang = 'fr';

In tags syntax :

(% contact fr %)

Fields checklists

These options allows to define required or prohibited terms for specific fields types.

The first field indicates the field type, for example email, the second input define the rule type :

  • Blacklist : prohibited values that must not be present in the given field.
  • Whitelist : possible values required for the given field.

The last field contains the list of terms, separated by commas.

Security

These options allow to configure the security mechanisms included by default or to setup additional measures.

Setting Description
Use hidden honeypot field Add to every forms a hidden field that should not be filled. Humans won't see it, but most spam bots will fell in the trap.
Minimum time after page load Minimum number of seconds between a page load and a form submission. Fellow humans need at least a few seconds to read, fill and submit a form. Robots don't.
Minimum time between two submissions Minimum number of seconds between two form submissions.
Maximum submissions by hour Maximum number of submissions every hour.

The system will also detect and prevent the user to send again a submitted form (ex. reloading the page).

The native anti-spam and anti-error mechanisms should prevent all undesirable submissions. If you need a higher level of security you can insert a Google reCaptcha by using a captcha field and defining the public and secret keys.

Debug mode

These settings may be useful for debugging.

Setting Description
Disable all forms Disable mail sending, without hiding the contact forms.
Debug mode Disable mail sending, display p01contact health checks, data structures, data sent by POST and the email that would have been sent. Don't active that on production website!

The debug data can be shown with :

$p01contact->debug();

Syntax

This page describe the tags syntax that can be parsed from text, for exemple from CMS pages content. Each tag generates a distinct functional form.

This is a default contact form :

(% contact %)

Simple.

Parameters are separated by commas and listed after a semicolon.

(% contact : parameter, parameter, ... %)
(% contact : 
    parameter,
    parameter,
    ...
%)

Parameters can be email addresses or fields.

(% contact : address@domain.ext, another@domain.ext, ... %)
(% contact : field, field, field, ... %)
(% contact : address@domain.ext, field, field, ... %)

If you don't specify addresses, the form will use the default ones defined in settings. If you don't specify fields, the form will use the default ones defined in settings.

Form-specific language

The word contact may be followed by a two-letters language code to set the form language. Known fields and messages will be translated (see i18n).

(% contact fr %)

Fields types

Any standard field type will be displayed accordingly on the form and will report its value in the received email.

Standard fields types
text one-line text field
textarea multi-line text area
checkbox one or more check boxes and labels
radio one or more radio buttons and labels
select drop down list with defined values
email, url, tel,
date, month, week, time,
number, color, range, search
HTML5 inputs

Modern browsers will provide suitable fields inputs and validate their content. Some of them are also validated server-side like email, url and tel.

Some fields types will have an additional behavior :

Special fields types
name a text field used as source name in the received email.
email is used as source address in the received email.
subject a text field used as subject in the received email.
askcopy a checkbox allowing the user to receive a copy of the email.
message textarea with a minimum text length that can be defined in settings.
captcha a Google reCapcha field (must be configured in the settings).
password password field with required input server side verification.

Fields options

The field options are defined after the field type, to customize it.

Symbol Description Note Example
! Required field A required field left empty will display a "required" error. email!
"..." Custom label Will replace the default one. email "Your email"
(...) Description Shown next to the label. message (please be polite)
= ... Default value or
Required value
The value will be pre-filled when it makes sense. name = Jean-Claude
password = secret1234
=< ... Placeholder value Shown when the field is empty. email =< name@domain.com
=> ... Locked value The field value will be set and not editable. subject => Love enquiries

Checkbox, radio and select fields default value may have multiple options separated by vertical bars. By using a semicolon next to an option, you can define the selected one(s).

checkbox = a single option
checkbox = an option |: a selected option |: another selected option
radio = an option |: the selected option
select = option one | option two |: selected option three

Multiple options have to be used in the following order :

fieldType! "text" => value | value

Examples

Default :

(% contact %)

Default with two custom recipients :

(% contact : recipient@domain.ext, other@domain.ext %)

A custom minimal one :

(% contact : email!, message! %)

A custom big one :

(% contact fr : 
    address@domain.ext, another@domain.ext,
    subject => "About this script",
    email!,
    textarea "How old is born Napoléon?",
    tel,
    radio "Do you like this script?" = Yes | No, 
    url (Website or blog),
    select = One | Two :| Three | Four | Five ,
    message! = Say something,
    password = tomato,
    askcopy
%)