Thursday, 12 July 2012

How to add a extra field “Contact Us” form in magento

Step One: Modify the (interface)/(theme)/template/contacts/form.phtml file.
Say we would like to add a field called ‘Test’ in between e-mail and telephone on the default field.

  1. <div class="input-box">
  2.                     <label for="email"><?php echo $this->__('Email') ?> <span class="required">*</span></label><br />
  3.                     <input name="email" id="email" title="<?php echo $this->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text"/>
  4.                 </div>
  5.                 <div class="clear"></div>
  6.                 <div class="input-box">
  7.                     <label for="telephone"><?php echo $this->__('Telephone') ?></label><br />
  8.                     <input name="telephone" id="telephone" title="<?php echo $this->__('Telephone') ?>" value="" class="input-text" type="text"/>
  9.                 </div>
    Here is the new field

  1. <div class="input-box">
  2.                     <label for="email"><?php echo $this->__('Email') ?> <span class="required">*</span></label><br />
  3.                     <input name="email" id="email" title="<?php echo $this->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text"/>
  4.                 </div>
  5.                 <div class="clear"></div>
  6.                 <div class="input-box">
  7.                     <label for="test"><?php echo $this->__('Test') ?></label><br />
  8.                     <input name="test" id="test" title="<?php echo $this->__('Test') ?>" value="" class="input-text" type="text"/>
  9.                 </div>
  10.                 <div class="input-box">
  11.                     <label for="telephone"><?php echo $this->__('Telephone') ?></label><br />
  12.                     <input name="telephone" id="telephone" title="<?php echo $this->__('Telephone') ?>" value="" class="input-text" type="text"/>
  13.                 </div>
    Step Two: Create the new Transactional E-Mail form.
    1) Go to System→Transactional E-mails in the Magento Admin section. 2) Click ‘Add New Template’ 3) From the ‘Template’ dropdown box select ‘Contact Form’ 4) Click ‘Load Template’ 5) Under template content you will see:

    1. Name: {{var data.name}}
    2. E-mail: {{var data.email}}
    3. Telephone: {{var data.telephone}}
    4. Comment: {{var data.comment}}
      Add your new field in between E-mail and Telephone: 


    1. Name: {{var data.name}}
    2. E-mail: {{var data.email}}
    3. Test: {{var data.test}}
    4. Telephone: {{var data.telephone}}
    5. Comment: {{var data.comment}}

No comments:

Post a Comment

Note: only a member of this blog may post a comment.