Display a contact form on the site, manage entries on admin

The dmContactPlugin allows to display a typical contact form.
By default, contact requests sent with the form are stored in database.
The plugin packages a Diem front widget and an admin interface to manage contact requests.
Integrates recaptcha validation.

See it in action on the contact page

Installation

  • In a console, from your project root dir, run:
git clone git://github.com/ornicar/dmContactPlugin.git plugins/dmContactPlugin  
  • In config/ProjectConfiguration.class.php, add dmContactPlugin to the list of enabled plugins:
class ProjectConfiguration extends dmProjectConfiguration
{  
  public function setup()  
  {  
    parent::setup();  
 
    $this->enablePlugins(array(  
      // your enabled plugins  
      'dmContactPlugin'  
    ));  
  • In a console, from your project root dir, run:
php symfony doctrine:generate-migrations-diff  

php symfony doctrine:migrate  

php symfony dm:setup  

Display the form on the front

Open the front "Add" menu, and drag&drop a contact/form widget somewhere on your site.

Manage contact requests on admin

Open Content->Feedback->Contacts on admin menu.

Enable captcha validation

This step is facultative, but will help you fighting against spam.
Add this configuration in
apps/front/config/app.yml

all:  
  recaptcha:  
    # get your recaptcha keys on http://recaptcha.net/api/getkey  
    public_key:   6LeefAkAAAAAAF-this-is-a-dummy-public-key  
    private_key:  6LeefAkAAAAAA-this-is-a-dummy-private-key  
    enabled:      true  

You will need to get API keys from the recaptcha website. It's free.

Customize form style

You may just use CSS if the default outputed HTML looks fine to you.

Or you can override the form template by copying
dmContactPlugin/modules/dmContact/templates/_form.php
to
apps/front/modules/dmContact/templates/_form.php

Add fields to the form

The default form is quite basic. Let's say you wanna add a "subject" field.

Override the model schema

Add these lines in your project schema
config/doctrine/schema.yml

DmContact:  
  columns:  
    subject:          { type: string(255), notnull: true }  

Then run the required doctrine migrations and setup your project

php symfony doctrine:generate-migrations-diff  
  
php symfony doctrine:migrate  
  
php symfony dm:setup  

The DmContact model and form are now up to date and contain the subject field. We still have to display the on front and admin.

Update the front template

Copy
dmContactPlugin/modules/dmContact/templates/_form.php
to
apps/front/modules/dmContact/templates/_form.php

then add the "subject" field somewhere, for example just after the form tag.

echo $form->open();
 
echo $form['subject']->label()->field()->error();  

Update the admin interface

Copy
dmContactPlugin/modules/dmContactAdmin/config/generator.yml
to
apps/admin/modules/dmContactAdmin/config/generator.yml

and paste this configuration inside:

generator:  
  param:  
    config:  
      list:  
        display:  
          - '=name'  
          - subject  
          - email  
          - body  
          - created_at  
          - updated_at  
      form:  
        display:  
          NONE: [name, email]  
          Body: [subject, body]  

Learn more about symfony admin generator.

Customize model and form

you can override the DmContact model in your project
lib/model/doctrine/dmContactPlugin/DmContact.class.php

and the DmContactForm form in your project
lib/form/doctrine/dmContactPlugin/DmContactForm.class.php

Do something when a contact request is saved.

Listen to the 'dm_contact.saved' event in
apps/front/config/frontConfiguration.class.php

require_once(dm::getDir().'/dmFrontPlugin/lib/config/dmFrontApplicationConfiguration.php');
 
class frontConfiguration extends dmFrontApplicationConfiguration  
{  
  public function configure()  
  {      
    $this->dispatcher->connect('dm_contact.saved', array($this, 'listenToContactSavedEvent'));  
  }  
 
  public function listenToContactSavedEvent(sfEvent $e)  
  {  
    $contact = $e['contact'];  
    // do something with the freshly saved $contact  
  }  
}  
  • RenatoJuly 1, 2010 4:06 PM

    Hi, I get the error Could not generate migration classes from difference, when running doctrine:generate-migrations-diff

  • JérémyApril 13, 2011 1:49 PM

    It's normal, nothing has changed in your schema.yml

  • zelsteeceNovember 7, 2012 6:32 AM

    http://www.jerseyswholesalezone.com/ nfl jerseys wholesale
    http://www.jerseyswholesalehome.com/ cheap nfl jerseys china
    http://www.cheapjerseycenter.net/ cheap nfl jerseys
    http://www.cheapjerseyssea.com/ cheap nfl jerseys china
    http://www.nflstarsjerseys.com/ cheap nfl jerseys
    [url=http://www.jerseyswholesalezone.com/]nfl jerseys china[/url]
    [url=http://www.jerseyswholesalehome.com/]cheap nfl jerseys china[/url]
    [url=http://www.cheapjerseycenter.net/]cheap nfl jerseys[/url]
    [url=http://www.cheapjerseyssea.com/]cheap nfl jerseys[/url]
    [url=http://www.nflstarsjerseys.com/]nike nfl t-shirts[/url]
    <a href=http://www.jerseyswholesalezone.com/>nfl jerseys wholesale</a>
    <a href=http://www.jerseyswholesalehome.com/>cheap nfl jerseys china</a>
    <a href=http://www.cheapjerseycenter.net/>cheap nfl jerseys</a>
    <a href=http://www.cheapjerseyssea.com/>nfl jerseys wholesale</a>
    <a href=http://www.nflstarsjerseys.com/>cheap nfl jerseys</a>

  • TildavalaNovember 16, 2012 10:07 PM

    mgyhisdoa
    http://www.bootsforsalejp.com/ ugg クラシック
    http://www.bootuggjp.com/ ugg 新作
    http://www.jpbootsshop.com/ ugg ブーツ
    http://www.bootsforgirlsjp.com/ ugg ムートン
    http://www.bootssnowjp.com/ ugg 新作

    tbkndqgpx
    <a href=http://www.bootsforsnowjp.com/#aplqlrnau>ugg ムートン</a>
    <a href=http://www.jpbootsforkids.com/#ckimotibd>ugg ブーツ</a>
    <a href=http://www.bootslovesnow.com/#jpyfrppaw>ugg</a>
    <a href=http://www.bootsforkidsjp.com/#ivoxrbwvy>ugg 安い</a>
    <a href=http://www.lovebootsjp.com/#znjclkouf>アグ</a>

    qjehdxthu
    [url=http://www.uggcheapjp.com/#gwbiefutb]ugg ムートン[/url]
    [url=http://www.jpbootshoes.com/#q#sbuoamsa]アグ[/url]
    [url=http://www.bootsforkidsjp.com/#qfraguory]ugg ムートン[/url]
    [url=http://www.jpbootsforcheap.com/#enjhlhjap]ugg クラシック[/url]
    [url=http://www.bootcityjp.com/#epxuvvker]アグ[/url]

  • TrodosoureParDecember 4, 2012 11:35 PM

    After we think about the concise explaination the saying love, with relations to a romantic romance using one more, although as a sensation that's engendered if you have miltchmonkey the best relationship on your own also , or even being a sensation of larger oneness with your family or man ( space ) this results in being even more crystal clear that every anybody needs in life can be really enjoy.

  • vereSeiltJanuary 18, 2013 5:32 AM

    Todays [url="http://www.montblancpensforsale.com/designer-limited-edition-ballpoint-pen-blue-Products-327.html
    "]http://www.montblancpensforsale.com/designer-starwalker-ballpoint-pen-steel-blue-Products-426.html
    [/url] has been formed by means of the Simplo Filler Pen Company related with Hamburg, Germany established around 1906. The business started simply because the union of experience as well as information of the engineer,Wilhelm Dziambor, a new finansieringsselskaber, Orlando Lausen along with a stationer, Claus Johannes Voss. In a size of 3 many years, the enterprise obtained their boutiques started in London, London alongside with Barcelona. One full calendar year many the corporation grew to turn out to be severely intrigued in promoting and marketing and advertising their model title. The firm has been rebranded because "Montblanc", subsequent the expertise European pile as a symbol of the high aspirations from the leaders for the manufacturer identify and their good quality.

    [url="http://www.montblancpensforsale.com/cheap-ordinary-fountain-pen-gold-black-004-Products-411.html
    "]mont blanc pen holder
    [/url] even delivers a tale using the Oscars. This yr too the maker returned for the Academy awards and also co-hosted any star-studded drink operate with Soho House, Gulf Hollywood. Scenario would have been a social gathering from the Weinstein Corporation's Academia Merit nominees with each other with Montblanc's headline of the company's charitable organisation collaboration that could profit the Princess or queen Sophistication Foundation-Usa. Case ended up getting acknowledged by a amount of intercontinental superstars which contain Ben Hooper, Colin Firth, Jennifer Lopez, Helena Bonham Billings, Kate Walsh, Adrien Brody, Emma Rock, Taylor Swift and many various other [url="http://www.montblancpensforsale.com/designer-boheme-black-white-rouge-ballpoint-pen-with-friar-Products-10.html
    "]mont blanc mini pen
    [/url].
    Annually [url="http://www.montblancpensforsale.com/cheap-limited-edition-fountain-pen-white-black-Products-317.html
    "]cheapest mont blanc pens
    [/url] declares it's calendar year-lengthy charitable business undertaking around the event with the Academy Awards. The current 12 months collaboration involving Montblanc as nicely as the Princess Sophistication Foundation-United states is targeted in direction of determining and also supporting flourishing skills within dancing, film and cinema just by awarding awards even though apprenticeships, scholarship grants and also fellowships. The real Small princess Grace Basis exhibits Passionate Grace regarding Monaco's willpower to assist promising musicians to appreciate his or her possible.

Add a comment

Impossible to fetch issues for this plugin.
Impossible to get this plugin changelog.

dmContactPlugin, created on January 25, 2010 by Thibault D, used by 1978 projects

Fork Diem on GitHub