08
Mar
How to enable the default Magento contact form?
- System > Configuration > Contacts
- Click the ‘Contact Us’ section on this page. Set ‘Enable Contact Us’ to ‘Yes’
- Click the ‘Email Options’ section on the same page, just under it. Set the email address to which the comments should come, subject and email template.
- Click ‘Save Config’
How to add a custom field to the default Magento contact form?
- Open [magento_root]/app/design/frontend/default/default/template/contacts/form.phtml in your favorite editor
- Copy & paste an existing form field code on this script and rename the field to create new field. For example:
This is the default code in the file:<div class="input-box"> <label for="email"><?php echo Mage::helper('contacts')->__('Email') ?> <span class="required">*</span></label><br /> <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" /> </div> <div class="clear"></div> <div class="input-box"> <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label><br /> <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" /> </div>This is how the modified code will look like:
<div class="input-box"> <label for="email"><?php echo Mage::helper('contacts')->__('Email') ?> <span class="required">*</span></label><br /> <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text" /> </div> <div class="clear"></div> <!-- New Field Code--> <div class="input-box"> <label for="website"><?php echo Mage::helper('contacts')->__('Website') ?></label><br /> <input name="website" id="website" title="<?php echo Mage::helper('contacts')->__('Website') ?>" value="" class="input-text" type="text" /> </div> <div class="clear"></div> <!-- End New Field Code--> <div class="input-box"> <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label><br /> <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" type="text" /> </div> - Now go to, System > Transaction Emails.
- Click ‘Add New Template’
- In the ‘Load default template’ section, select ‘Contact Form’ template and click ‘Load Template’
- The template content will look like this:
Name: {{var data.name}} E-mail: {{var data.email}} Telephone: {{var data.telephone}} Comment: {{var data.comment}} - Add your new field in this content like this:
Name: {{var data.name}} E-mail: {{var data.email}} Website: {{var data.website}} Telephone: {{var data.telephone}} Comment: {{var data.comment}} - Enter a new ‘Template Name’ and click ‘Save template’
- Now go to, System > Configuration > Contacts
- Click the ‘Email Options’ section on this page and select the new template that you just created.
- Click ‘Save Config’
How to add a link to the contact form on the top menu bar?
- Open [magento_root]/app/design/frontend/default/default/template/catalog/navigation/top.phtml in your favorite editor
- After this line:
<?php endforeach ?>
Add a line like this:
<li><a href="<?php echo $this->getUrl('contacts')?>"><?php echo $this->__('Contact Us') ?></a></li> - Click the Magento cache; System > Cache Management
Reference links:




