Hi, it would be better to bring more secrets in your episode, this beginner stuff is crap ..sorry
Adding a Contact Form to a Drupal 7 Site
Share with Others
In this episode we will go over how to add a contact form to a Drupal 7 website using the Drupal contact module. In this episode you will learn:
- How to use the Drupal 7 core contact form module to display a simple contact form on your Drupal site.
- How to set up the Drupal contact form to send emails to different email addresses depending on the topic of the contact form submission.
Welcome to another Daily Dose of Drupal, this is Episode 10 and this is brought to you by codekarate.com. Today we are going over a very simple Drupal concept. We’re just going to be adding a Contact Form to our Drupal site and in this episode we’re going to use the Drupal Core Contact module and we’ll start off by going to the modules page and you’ll notice that in the core group of modules there’s a module called Contact and let’s go ahead and scroll down and we’ll click on Save and immediately right out of the box that’s all you need to do to get to a Contact Page.
You’ll notice that we now have a Contact page where you can put your name, e-mail address, subject and message and it will send a message to the … whatever you have as a site e-mail for your Drupal site.
If you go into Structure we can change some of these settings, there’s a Contact Form Administration page here and there’s a few things you’ll notice here; there’s a link right there to your Contact Form, it says that there’s a Menu Item that you can turn on if you want and it also says if you’d like to add additional content to the Content Page you can do so as a block which will go over that here in a second but we’ll go ahead and add another category and we’ll call this General Info; you can put who you’d like to receive this.
So just make up an e-mail for now, if you want to have an auto-reply so that it will send the user an auto-reply message; you can say “thanks for contacting me” and you can select if you want this one to be selected by default. So now that you have two; if you go back to your Contact page there’s a category list in here and this will allow you to select what type of category this contact will be in when the user goes to submit a contact form and it will send it to whatever e-mail address is set in that Con tact Form.
So you’ll notice here this is the actual site address or site e-mail for the Drupal 7 site but you can always come in and change it, so we can change that, hit Save and now we have two different e-mail addresses so you could have support questions go to a Support Team and product related questions go to a Sales Team and you could route things that way.
So let’s go back to our Contact Form; it’s very simple, we’re just going to add a little bit of text up here; so go into Structure Blocks and we’re going to add a new block, we’ll call the title Contact Us and we’ll say Contact Form Text and I just added some tags in there so you can see that you can use HTML to format this, you could do whatever you need to make the contact page look better and we only want to show this on the contact page and the reason we want to do this is because we obviously don’t want this block showing up on other pages, we’ll leave everything else the same and hit Save Block and then we will go ahead and find this block which should be down here and disabled and we can drag it up to … we can put it in the Feature section and we’ll say of our team, we save that and go back to the Contact page and you’ll see now we have this Contact Us text in the featured section.
We can always move that of course to the main content section, save it and now it’s going to show up here. So there’s a couple of things that you can do to increase the design or enhance the design of your Contact page. One thing you’ll notice is that obviously limited on the fields that you can use and you’re kind of stuck with what it gives you.
There’s a couple of ways you can change that; you can either create a custom module and add some fields using the form API which I might suggests if you’re working on a very large site that is using multiple environments and version control but if you just need a contact form for a simple site then you may need to look into the Web Form module and that’s what we’re going to go over next time.
So until net time, this is the Daily Dose of Drupal, you can follow me on Twitter @smthomas3 and subscribe to my codekarate.com newsletter and I will see you next time.
Find out what you're missing with our 5 Secrets to becoming a Drupal 7 Ninja
Well it's a fine line that I am trying to tread with these videos... because this is a very beginner topic, however there are a lot of people that are Drupal beginners that need this stuff too. Obviously this does no good to anyone who has built a few sites in Drupal...
I do want to introduce more module development and theme development concepts in some of my videos, however I haven't decided how to do that. It is difficult to really get into a more complex topic in only 5 to 10 minutes.
What would you like to see more of?
If you wanted to make it a bit less beginner I would recommend using the webform module for contact forms.
I don't know any developers who use the drupal core contact form.
Webform has the advantage of allowing any fields, great customisation of emails, many additional add on modules for extra features, and it stores submissions in the database so admins can come back and view them later.
The next video or two I post will be on the Webform module (as hinted in the video above). I tend to agree with your recommendation about using webform, however I have found that not all Drupal developers feel the same way.
To summarize the arguments against using Webform for contact forms... They are technically content on your website, this means it makes managing a development/staging/live environment much more difficult because the webform is stored in the database. If you make a change to a webform in one environment it is not easy to push the changes up to other environments.
You can read the comment thread above to see more details on the full Webform/Contact form conversation I had with another Drupal developer.
Thanks for the link.
It is good to see some arguments against it, although for my use I think webform is better suited in most cases.
The flexibility of email settings it provides is great.
Maybe I can look at doing some drupal patches to add some better configurability to core.
I might also have a look at that contact save module and port it to drupal 7.
i am using webform 7.x-3.18 in my drupal site. my problem is i am getting same mail 10 times in my inbox when someone do submission. i had checked it's not spamming.
I for one am so grateful for a simplified intro to creating forms. Some of us new to Drupal prefer to learn to walk before we run and just want a clear yet concise how-to. So many tutorials out there gloss over some very basic information, without which, the newbie is lost. I look forward to viewing other tutorials and many thanks for the help!
Hi! I am using the same thing just like the tutorial. But the mail is not submit, without any error message. Thaanks for help.
Shane - ignore the nonsense comments. Your tutorials are awesome, and you are awesome, keep on the great work! To critics - Webform is not necessarily the best practice, as it goes against Drupal's standard API.
Hi there, i liked your tutorial, but i'd like to know how i can change the title of the contact form itself from the default which is just Contact...please give me some guidance on how i can go about that,