很多时候,Magento自带的contact form的字段并不符合我们的要求,我们会在原有的基础上面增加某些字段,那应该如何进行操作呢?下面给出详尽的解决方案。
此处示例的是添加一个Subject字段在原有的form之上,首先找到这个文件:
/magento_root/app/design/frontend/YOUR_INTERFACE/YOUR_THEME/template/contacts/form.phtml
<div class="input-box">
<label for="name"><?php echo Mage::helper('contacts')->__('Name') ?> <span class="required">*</span></label><br />
<input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="required-entry input-text" type="text"/>
</div>
在这段code后面添加如下的code,
<div class="input-box">
<label for="subject"><?php echo Mage::helper('contacts')->__('Subject') ?> <span class="required">*</span></label><br />
<input name="subject" id="subject" title="<?php echo Mage::helper('contacts')->__('Subject') ?>" value="" class="required-entry input-text" type="text"/>
</div>
将新加的字段加到email template里面,进入后台,点击System->Transactional E-mails,点击”Add New Template”在”Template”下拉框里面选择 “Contact Form”然后”Load Template”,这样你会看到,
在这个上面我们添加刚刚的Subject字段
Subject: {{var data.subject}}
Name: {{var data.name}}
E-mail: {{var data.email}}
Telephone: {{var data.telephone}}
Comment: {{var data.comment}}
{{block type=”core/template” name=”contactForm” form_action=”/contacts/index/post” template=”contacts/form.phtml”}}