tmcContactPlugin - 1.0.0

Contact form plugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

tmcContact plugin (for symfony 1.4) by Tito Miguel Costa symfony@titomiguelcosta.com

The tmcContactPlugin is a symfony plugin that provides a contact form.

It gives you the model (tmc_contact) and the modules (tmcContact and tmcContactAdmin).

It allows a user to fill in a simple contact form and submitting to an e-mail, saving the information in a database.

All in a configurable plugin.

Installation

  • Add the channel to your project

    symfony plugin:add-channel pear.titomiguelcosta.com
    
  • Install the plugin (via a package)

    symfony plugin:install pear.titomiguelcosta.com/tmcContactPlugin
    
  • Activate the plugin in the config/ProjectConfiguration.class.php

    class ProjectConfiguration extends sfProjectConfiguration
    {
      public function setup()
      {
        $this->enablePlugins(array(
          'sfDoctrinePlugin', 
          'tmcContactPlugin',
          '...'
        ));
      }
    }
  • Rebuild your model

    symfony doctrine:build-model
    symfony doctrine:build-sql
    
  • Update you database tables by starting from scratch (it will delete all the existing tables, then re-create them):

    symfony doctrine:insert-sql
    

    or do everything with one command

    symfony doctrine:build --all`
    
  • Enable one or more modules in your settings.yml (optional)

    • For your backend application: tmcContactAdmin

        all:
          .settings:
            enabled_modules:      [default, tmcContactAdmin, ...]
      
    • For your frontend application: tmcContact

        all:
          .settings:
            enabled_modules:      [default, tmcContact, ...]
      
  • Clear you cache

    symfony cc
    

Customize the behaviour of the plugin in app.yml

all: tmcContactPlugin: cc_to_sender: false # send a copy of the e-mail to the user email_partial: tmcContact/email # partial that renders the e-mail email_from: from@example.com email_to: to@example.com email_subject: contact form subject redirect: tmc_contact # route to redirect after e-mail sent show_errors_top: true contact_form_id: contact_form # id of the form for javascript and css subject_widget: enabled: true type: text #or choice choices: {} attachment_enabled: true

Customize sfGuardAuth module templates

By default, tmcContact module comes with 2 very simple partials:

  • _email.php
  • _form.php

If you want to customize one of these templates:

  • Create a tmcContact module in your application (don't use the init-module task, just create a tmcContact directory)

  • Create a template with the name of the template you want to customize in the tmcContact/templates directory

  • symfony now renders your partial instead of the default one

Customize tmcContact module actions

If you want to customize or add methods to the tmcContact:

  • Create a tmcContact module in your application

  • Copy the actions.class.php in the module tmcContact to your actions directory

Customize tmcContact redirect handling

If you want to redirect the user to a diferent page, you can specify the route in the app.yml file.

You can change the redirect values in app.yml:

all:
  tmcContactPlugin:
    redirect:      tmc_contact # the plugin uses the @tmc_contact by default

The flash user variable $object will be available with the contact object.

Customize tmcContact widgets

It is possible to enable/disable the subject and attachment widget in the app.yml configuration file. For the subject widget, if enabled, it is even possible to specify if the kind of widget, a text or a select box.

all:
  tmcContactPlugin:
    subject_widget:
      enabled:              true
      type:                 choice #or text
      choices:              { 'support': 'Need help', 'other': 'Other topic' }
    attachment_enabled:     true