Skip to content

Latest commit

 

History

History
118 lines (98 loc) · 4.1 KB

README.md

File metadata and controls

118 lines (98 loc) · 4.1 KB

Contact plugin for Flextype

Version License Total downloads Flextype Discord

Dependencies

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

Installation

  1. Download & Install all required dependencies.
  2. Create new folder /project/plugins/contact
  3. Download PHP Mailer Plugin and unzip plugin content to the folder /project/plugins/contact
  4. Copy _project folder content into your project folder.

Documentation

Settings

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 [email protected] From email
to.name Flextype Receiver name.
to.email [email protected] Receiver email

Create your own contact form

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

Usage in the PHP

// 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()), []);

Usage in the TWIG templates

{# 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 }}

LICENSE

The MIT License (MIT) Copyright (c) 2021 Sergey Romanenko