【发布时间】:2015-04-30 09:22:47
【问题描述】:
我还是 Magento 的初学者,并尝试学习如何创建模块。现在我正在开发一个模块,它允许客户在结账时添加评论。
现在我在实现 textarea 时遇到了问题,我在 app/design/frontend/base/default/layout 和 app/design/frontend/base/default/template 下创建了一个名为“practice”的新文件。我在模块的 config.xml 文件中上传了新的布局文件。但是在结帐过程中没有任何文本区域,即使上传了正确的模板(我激活了模板路径提示选项以查看每个块的路径)。
app/code/local/Practice/CheckoutComments/etc/config.xml
<frontend>
<layout>
<updates>
<checkoutcomments>
<file>practice/checkoutcomments.xml</file>
</checkoutcomments>
</updates>
</layout>
</frontend>
这是 layout.xml 文件和我覆盖的 phtml.file 的代码:
app/design/frontend/base/default/layout/practice/checkoutcmets.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<checkout_onepage_review translate="label">
<reference name="checkout.onepage.agreements">
<action method="setTemplate">
<template>practice/checkoutcomments/onepage/comment-agreements.phtml
</template>
</action>
</reference>
</checkout_onepage_review>
</layout>
app/design/frontend/base/default/template/practice/checkoutcmets/onepage/comment-agreements.phtml
<?php
/**
*
* @see Mage_Checkout_Block_Agreements
*/
?>
<!-- Start of CheckoutComments module code -->
<form action="" id="checkout-agreements" onsubmit="return false;">
<ol class="checkout-agreements">
<div>
<br /> <label for="checkoutcomments"><?php echo Mage::helper('core')->__('Add your Comment for this Order') ?></label>
<textarea name="checkoutcomments" id="checkoutcomments"
style="width: 450px; height: 100px;"></textarea>
</div>
<!-- End of CheckoutComment module -->
<?php if ($this->getAgreements()) : ?>
<?php foreach ($this->getAgreements() as $_a): ?>
<li>
<div class="agreement-content"
<?php echo ($_a->getContentHeight() ? ' style="height:' . $_a->getContentHeight() . '"' : '')?>>
<?php if ($_a->getIsHtml()):?>
<?php echo $_a->getContent()?>
<?php else:?>
<?php echo nl2br($this->escapeHtml($_a->getContent()))?>
<?php endif; ?>
</div>
<p class="agree">
<input type="checkbox" id="agreement-<?php echo $_a->getId()?>"
name="agreement[<?php echo $_a->getId()?>]" value="1"
title="<?php echo $this->escapeHtml($_a->getCheckboxText()) ?>"
class="checkbox" /><label for="agreement-<?php echo $_a->getId()?>"><?php echo $_a->getIsHtml() ? $_a->getCheckboxText() : $this->escapeHtml($_a->getCheckboxText()) ?></label>
</p>
</li>
<?php endforeach ?>
<?php endif; ?>
</ol>
</form>
我停用了我的模块并使用上面自定义的 pthml.file 覆盖了app/design/frontend/base/default/template/checkout/onepage/agreements.phtml 的代码,然后出现了文本区域!我猜我的配置文件有问题,但我引用了正确的块,因为该块已上传但没有任何文本区域。
希望你能帮到我
问候
【问题讨论】:
标签: checkout magento-1.9