Eric Barnes

Statamic Email Form Plugin

This is a plugin for Statamic that is designed to allow you to quickly and easily create email forms. Currently it is pretty basic but flexible so it should be a great starting point. I hope to get feedback on this release and then make improvements over time.

Installation

Copy the “email” folder to your _add-ons directory.

Example Form Template

Here is a full example to get you going. Please see the parameters section for more field options:

{{ email:form subject="Contact Form" to="eric@ericlbarnes.com" required="name" }}
    {{ if error}}
        <h1>Error</h1>
        <ul>
        {{ errors }}
            <li>{{error}}</li>
        {{ /errors }}
        </ul>
    {{ endif }}

    {{ if success }}
        <h1>IT WORKED!</h1>
    {{ else }}
        <p>
            <label for="name">Name:</label>
            <input type="text" name="name" id="name" value="Bill">
        </p>
        <p>
            <label for="from">Email:</label>
            <input type="text" name="from" id="from" value="test@test.com">
        </p>
        <p><input type="submit"></p>
    {{ endif }}
{{ /email:form }}

Parameters

The {{ email:form }} tag accepts the following paramaters:

  • subject: The subject of the email.
  • to: The form recipient’s email address.
  • cc: A cc email address.
  • bcc: A bcc email address.
  • required: A pipe seperated list of required fields. Example: “name|address|city”. Currently this only does simple validation to check if it is an empty value.

Issues / Gotchas

The name field is hard coded as the reply name in the plugin so it is recommended you use this field in your form.

Contribute

Keep in mind this is the first release so if you see any issues or have ideas for improvements pull requests are gladly accepted. ;-)

Download

You can clone the repo by running the code below:

$ git clone git@github.com:ericbarnes/Statamic-email-form.git

Or visit the GitHub Repo.

A few days ago I released a simple Statamic sitemap template and it works just fine for my personal use on this site. If you are interested in a much better version check out Max Westen’s Sitemap Plugin. It offers the following features mine does not:

It fetches all pages/entries and folders, without specifying them and updates the updatefreq dynamically based on last edit time. Also it uses the priority given in the yaml parameter on pages and/or entries.

He also several other plugins for Statamic that you may find useful:

David Walsh has a great post on “Being a Good Member of the Community” in which he outlines 7 steps. My personal favorite is the following:

Include, Don’t Exclude

This simple rule takes on a number of different meanings:

  • Don’t exclude known members of other communities; don’t be adversarial
  • Don’t exclude members of your own community that are known for different roles; let others dip their hands in all pots
  • Don’t exclude new people: every potential new member of the community has value

CodeIgniter url_title

The CodeIgniter url helper contains a very useful function named url_title(). This function is designed to take a string such as “my test string” and convert it to “my-test-string”. This works great for english characters but will/can fail when you throw in accented characters.

To get around this issue you will need to run the convert_accented_characters() on the string before passing it to the url_title. Here is a full example:

url_title(convert_accented_characters('My Café'));

I have seen several bug reports about this and to be honest I feel this is much more expressive than an alternative of:

url_title('My Café', 'dash', FALSE, TRUE); 

If you see the above code in a project can you tell what the FALSE and TRUE does? I even had to look up the function to find out what the current third param was. I had no idea it had a lowercase option. Which in my opinion is not even needed inside the function. Instead you should write it as:

strtolower(url_title('My Café', 'dash')); 

At the end of the day is writing two function calls that bad? It’s expressive, it does the job, and above all you get the same results.

Statamic Sitemap

This is just a few simple template files to generate a sitemap of your site for submitting to Google webmaster tools. It follows the sitemap protocol.

Installation

Copy the contents of all the directories and move them into your Statamic site.

Download

You can clone the repo by running the code below:

$ git clone git://github.com/ericbarnes/statamic-sitemap.git

Or visit the GitHub Repo.