So you have your fancy new site almost ready, but you realize you want a way for people to contact you. You need to build a contact form.
Things to know that will make this simpler:
- Graffiti themes are comprised of scriptable *.view files that define page contents and layouts.
- Pages named after these view files will adopt the layout defined on those view files.
- View files can use macros to output content. There is a “Contact Us” macro that can be used to generate a contact us form. ContactForm()
- Your theme may already define a layout (have a view file) for a contact us page. You’ll want to check before starting. To check log into the control panel, choose presentation -> themes -> personalize on your theme -> look for a .view file with a contact form.
If your theme defines a contact view you probably want to use that for starters.
- Record the name of the contact view. It’s most commonly “contact.view”.
- Click write and create a new post (it can be uncategorized)
- Name your post the same name as the contact view file. “Contact” in my case.
- Enter any information in the body you’d like to have on the contact page.
- Publish & View your contact page – You should now have a basic contact form as shown to the right.
- Now you probably want to add this page to your site navigation. To do this use the Navigation admin under presentation. Presentation > Navigation > Posts > Find the contact post and add it to the site navigation.
- You now have a contact form!
If your theme did not define a contact form.
- Contact the person who built the theme and slap them with a fish.
- Personalize your theme… choose presentation -> themes -> personalize on your theme.
- Click Create a new file for this theme.
- Name it appropriately – this will be the name of your contact page – contactus.view for example will work fine. 🙂
- Add “$macros.ContactForm()” to the contents of this file.
- Create a new post with the same name as the view file you just created.
- Publish & View your contact page – You should now have a basic contact form as shown to the right.
- Now you probably want to add this page to your site navigation. To do this use the Navigation admin under presentation. Presentation > Navigation > Posts > Find the contact post and add it to the site navigation.
NOTE: You’ll notice that this new page doesn’t contain the body of the post you just created. If you’d like to make the contact form look a little by adding the post contents try pasting the following into the contactus.view in step 5 instead of simply the contact form macro.
<div class=”article”>
<h1 class=”title”>$post.Title</h1>
<div class=”body”>
$post.Body
</div>
</div>
$macros.ContactForm()