Contact plugin for Flextype
The following dependencies need to be downloaded and installed for Contact Plugin.
Item | Version | Download |
---|---|---|
flextype | 0.9.16 | download |
site | >=1.0.0 | download |
twig | >=2.0.0 | download |
phpmailer | >=1.0.0 | download |
- Download & Install all required dependencies.
- Create new folder
/project/plugins/contact
- Download PHP Mailer Plugin and unzip plugin content to the folder
/project/plugins/contact
- Copy
_project
folder content into yourproject
folder.
Key | Value | Description |
---|---|---|
enabled | true | true or false to disable the plugin |
priority | 80 | contact plugin priority |
default_subject | Default subject | Default subject for email |
message_success | Email sended. | Message to show after email send. |
from.name | Flextype | From name |
from.email | sergey.romanenko@flextype.org | From email |
to.name | Flextype | Receiver name. |
to.email | sergey.romanenko@flextype.org | Receiver email |
here is an example of simple contact form:
title: Contact
default_field: title
icon:
name: envelope
set: 'fontawesome|solid'
size: 6/12
hide: true
form:
action: 'contact.contactProcess'
buttons:
submit:
type: submit
title: 'Send'
fields:
mailbox:
type: hidden
default: test
subject:
title: 'Subject'
type: text
size: 6/12
validation:
required: true
email:
title: 'Email'
type: email
size: 6/12
validation:
required: true
message:
title: 'Message'
type: textarea
size: 12
validation:
required: true
Read documentation about creating forms here:
https://github.com/flextype-plugins/form
// Show success message
if (isset(flextype('flash')->getMessages()['success']) and count(flextype('flash')->getMessages()['success']) > 0)
foreach (flextype('flash')->getMessages()['success'] as $message) {
echo $message;
}
}
// Render contact form
echo flextype('form')
->render(flextype('serializers')
->yaml()
->decode(filesystem()
->file(PATH['project'] . '/fieldsets/contact.yaml')
->get()), []);
{# Show success message #}
{% for message in flextype.flash.getMessages()['success'] %}
{{ message }}
{% endfor %}
{# Render contact form #}
{{ flextype.form.render(flextype.serializers.yaml.decode(filesystem().file(PATH_PROJECT ~ '/fieldsets/contact.yaml').get()), {})|raw }}
The MIT License (MIT) Copyright (c) 2021 Sergey Romanenko