lukeyouell / craft-contactformtemplates
Custom email templates for the Craft CMS Contact Form plugin
Installs: 1 489
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 0
Forks: 0
Open Issues: 3
Type:craft-plugin
Requires
- craftcms/cms: ^3.0.1
- craftcms/contact-form: ^2.1.1
This package is not auto-updated.
Last update: 2019-11-16 17:15:28 UTC
README
Contact Form Templates plugin for Craft CMS 3
Custom email templates for the Craft CMS Contact Form plugin
Requirements
This plugin requires Craft CMS 3.0.1 or later and Contact Form 2.1.1 or later.
Installation
To install the plugin, either install via the plugin store or follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require lukeyouell/craft-contactformtemplates
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Contact Form Templates.
Using Contact Form Templates
To use a custom email template simply add the following field to your form:
<input type="hidden" name="message[template]" value="{{ 'path/to/template'|hash }}">
The message[template]
value is used to source the template file located in templates/_emails
, this value must be hashed to avoid tampering.
Example
<input type="hidden" name="message[template]" value="{{ 'foo/bar'|hash }}">
Would look for the following template:
templates/_emails/foo/bar.twig
Template Variables
The submitted field values are available for use in your templates by using {{ submission }}
Example
<input type="text" name="fromName" value="Joe Bloggs">
Would be used in your templates using:
{{ submission.fromName ?? 'Fallback Value' }}
Which would output:
Joe Bloggs or Fallback Value
Contact Form Templates Roadmap
Some things to do, and ideas for potential features:
Brought to you by Luke Youell