Monday, March 19, 2007

Contact / Feedback Form Plugin for Mephisto

Introduction
If you use Mephisto, a content management / blogging system written in Rails, you may well be interested in using this new plug-in. It provides a form that lets visitors to your site leave their contact details and send you messages or feedback via email.

License
This plug-in was developed for the new ThoughtWorks Studios site. As I wrote it at and for work, it is copyright ThoughtWorks, 2007. However, ThoughtWorks, being generous souls, is happy for me to open source it under the Apache 2.0 licence, which pretty much means you have free reign to use it as you want.

Requirements
  • Mephisto Edge (the latest stable 0.7.3 release does not have support for Mephisto plugins)
  • Rails Edge (required by Mephisto edge)
  • ActionMailer (comes with Rails) correctly configured with SMTP server etc, so that emails can be delivered. See "Configuration" section here for more details.

Installation
ruby script/plugin install http://mephisto-contact-form-plugin.googlecode.com
/svn/plugins/mephisto_contact_form

or in your vendor/plugins directory for Mephisto:

svn checkout http://mephisto-contact-form-plugin.googlecode.com
/svn/plugins/mephisto_contact_form mephisto_contact_form

Make sure you restart your web server at this point so that the plugin is loaded.

Setup
1. Create a new template called 'contact_us.liquid' though the admin web interface (under the 'Design' tab).
Paste in the following code:

<H1>Contact Us</H1>
{% contactform %}
<p>{{ form.name }}<label for="author"><small>Your name</small></label></p>
<p>{{ form.email }}<label for="email"><small>Email address</small></label></p>
<p>{{ form.phone}}<label for="phone"><small>Phone number (optional)</small></label></p>
<p>{{ form.subject}}<label for="subject"><small>Subject</small></label></p>
<p>{{ form.body }}</p>
<p>{{ form.submit }}</p>
{% endcontactform %}

Feel free to modify labels, layout etc.

2. Edit
{MEPHISTO_ROOT}\vendor\plugins
\mephisto_contact_form\lib\contact_notifier.rb
and put in the email address you want contact form submissions to go to.

3. Link to "/contact_form" from your site.

Any issues / questions / suggestions?
Best to post comments on this blog.

Technical Info
The contact form plugin is actually a combination of a rails plugin, a liquid block plugin and a Mephisto plugin. See this post about developing Mephisto plugins for more information.

143 comments: