Multiple Categories with the Drupal Contact Module
Posted by drupallovers on March 30, 2012
The Drupal Contact module is often replaced by the Webform module. However, it can be useful in some situations. For example, image that you have different departments and you want each of them to get a different contact form on your Drupal website. If you’re willing to keep it simple, you can do everything you need with the core Contact module and won’t have to install anything else.
It all depends on knowing how to create categories and blocks.
Step 1. Make sure the Contact module is enabled
- Click Modules
- Click Save configuration.
- Click Configure next to Contact.
Step 2. Add and edit categories.
Click Add category to add a new one.
There is a default category called Website feedback that you can use as well, but we are showing you how to add extra ones. You can edit the default category later if you need to.
Step 3. Configure the category
- Give the category a name.
- Specify the Recipients
- Create an Auto-reply message.
- Set Selected. Yes means it will be the default contact form. Since this is a new category, you probably want this to be No. You can only have one default.*
- Be sure to click the Save button.
*Selected: When a visitor clicks on the link to the contact form, the categories will show in a drop down list. Whichever one is chosen with a “Yes” will show automatically If you want your visitor to be forced to choose a category before submitting the form, make all of these fields “No”
Continue repeating the process until you have all the categories you want. A “category” can be a different department, a group or individual.
Step 4. Enable the menu link
Jump to the Menus administration page by clicking the blue link in the instruction paragraph. Alternatively you can get their via the admin menu and clicking Structure then Menus.
Step 5. List the links
A Contact menu item (disabled by default) is added to the Navigation menu, which you can modify on the Menus administration page. Click list links next to Navigation.
Step 6. Enable the link
This menu link will go directly to the site-wide contact form. You will see a Contact menu item that is disabled. You can use this one as a guide for creating other menu links.
Step 7. Configure the link
- Edit the link title if needed.
- Enable the link so it appears on the menu.
- Choose the parent link if you want it to be different from the default “Navigation”.
Step 8. Add a block with instructions for the user
Go to Structure > Blocks.
Step 9. Add a block
Step 10. Add the block information
- Enter a Block Description. This will not be seen by the public.
- Enter a Block Title. This will be seen by the public.
- Write your instructions. This will also be visible to the public,
Scroll down the page.
Step 11. Set the visibility settings by assigning it to the Contacts page
- Choose “Only listed pages”. The only page we want to have these instructions is the Contact page.
- Write “contact” in the text field.
- Save the block.
Specify pages by using their paths. Enter one path per line. The ‘*’ character is a wild card. Example paths are blog for the blog page and blog/* for every personal blog.is the front page.
There are other parameters and settings on this page, but for the purpose of this tutorial we only need the basics.
Step 12. Enable the block
You will be returned to the Blocks page. You will find the block you added in the Disabled list with the title you created. To enable it, choose the position from the drop down box.
This box lists all of the regions available on the template you are using. On the Bartik template, the Help region is right where we want it. You may have a different idea or location on your website.
Step 13. Final configuration then save.
As soon as you choose the region, the block title will now be visible at the top of the page that shows the enabled modules. The will be grouped by region, so this one will be under Help.
Remember to Save – scroll to the bottom of the page
No changes will be saved until you click Save blocks.
If you followed all these steps you will have a contact form that looks something like this.
- There is a link on the menu to the form.
- The instructions are in the Help Region in a block you added.
- The correct email address shows. (this will change to the right one when the category is selected).
- There is a drop down list with the categories you created.