Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Orchard Contact Forms

I've been trying to setup a contact form via Orchard CMS v1.6 but I'm not really sure how to do it.

I tried installing the Custom Forms module but i think this isn't compatible with the latest version I'm using.

Any suggestions?

like image 476
Tay Avatar asked Feb 01 '13 10:02

Tay


1 Answers

The Custom Forms module is very powerful and flexible, but it's not obvious at first how to make a contact form using it. Once you've figured it out though you can do a lot more with it.

Step 1 - Create a content type for the contact information you want to collect

In /Admin/ContentTypes click 'Create new type' to make a type with all the info you want your user to fill in.

Step 2 - Create a Contact Custom Form Page

In /Admin/Orchard.Customforms create a new form. On the drop down for content type choose the new content type that you made in step 1. You probably want to also tick the 'Save the content item once the form is submitted' box. You don't need to as step 3 will show how to make it email you, but I like to do it in case there is a problem with email.

Step 3 - Create a rule to send you an email (In Orchard > 1.7 use a workflow)

In /Admin/Rules create a new rule.

In the events section select an event for When a custom form for types (Your new content type) is submitted.

In the actions section add an action to send an email. If you choose to send to admin, make sure you've given the admin user an email (or it just fails silently).

You can use tokens in the subject and body of the email. Mine looks like this:

**Subject:** Orchard Contact Form - {Request.Form:Contact information.Name.Text}

**Body:** Name: {Request.Form:Contact information.Name.Text}
Email: {Request.Form:Contact information.Email.Value}

{Request.Form:Contact information.Yourmessage.Text}

Name, Email, and Yourmessage are all the field names on the my 'Contact information' type. For you these will need to be the name of your content type and the fields you've added to it.

That's it.

Update: In Orchard 1.7 workflows have replaced rules. This blog post goes into more detail about how to use them to make contact form.

like image 191
Richard Garside Avatar answered Oct 19 '22 23:10

Richard Garside