magento中的联系我们页面未定义。 我如何从代码和管理面板定义contact-us页面。 由于cms中没有页面被命名为联系页面。
答案 0 :(得分:2)
在布局文件夹中添加contact.xml
<layout version="0.1.0">
<default>
<reference name="footer_links">
<action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
</reference>
</default>
<contacts_index_index translate="label">
<label>Contact Us Form</label>
<reference name="head">
<action method="setTitle" translate="title" module="contacts"><title>Contact Us</title></action>
</reference>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
</reference>
<reference name="content">
<block type="core/template" name="contactForm" template="contacts/form.phtml"/>
</reference>
</contacts_index_index>
</layout>
在cms和此代码中创建联系我们页面
{{block type="core/template" name="contactForm" template="contacts/form.phtml"}}
在以下路径app\design\frontend\theme\default\template\contacts\form.phtml
中创建模板文件
添加联系表单设计。例如
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
<section id="pr-contact" class="pr-main">
<div class="container"><h1 class="ct-header"><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1></div>
<div class="contact-map">
</div>
<div class="container">
<div class="col-md-3 col-sm-3 col-xs-12">
<div class="address">
<i class="fa fa-home"></i>
<p>
<span>Address</span><br/>
</p>
</div>
<div class="phone">
<i class="fa fa-phone"></i>
<p>
<span>Phone no:</span>
</p>
</div>
<div class="fax">
<i class="fa fa-fax"></i>
<p>
<span>Fax</span>
</p>
</div>
<div class="website">
<i class="fa fa-globe"></i>
<p>
<span>Website:</span>
</p>
</div>
</div>
<!--<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post" class="scaffold-form">-->
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post" enctype="multipart/form-data">
<div class="col-md-6 col-sm-6 col-xs-12">
<input name="name" id="name" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Name')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry name" type="text" placeholder="Enter your name *"/>
<input name="email" id="email" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Email')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email email" type="email" autocapitalize="off" autocorrect="off" spellcheck="false" placeholder="Enter E-mail *"/>
<input name="telephone" id="telephone" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Telephone')) ?>" value="" class="input-text" type="tel" placeholder="Enter Telephone *" />
<textarea name="comment" id="comment" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Comment')) ?>" class="required-entry input-text" cols="50" rows="10">Message *</textarea>
<!--<p>Ask us a question and we'll write back to you promptly! Simply fill out the form below and click Send Email.</p>
<p>Thanks. Items marked with an asterisk (<span class="star">*</span>) are required fields.</p>-->
<li>
<label for="attachment"><?php echo Mage::helper('contacts')->__('Attachment') ?></label>
<div class="input-box">
<input name="MAX_FILE_SIZE" type="hidden" value="2000000" />
<input name="attachment" id="attachment" class="input-text" type="file" />
</div>
</li>
<button type="submit" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Submit')) ?>" class="button sendmail"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
</div>
<div class="col-md-3 col-sm-3 col-xs-12">
</div>
</form>
</div>
</section>
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
//]]>
</script>