【问题标题】:Magento: Override phtml inside /base/default/templateMagento:在 /base/default/template 中覆盖 phtml
【发布时间】:2015-06-12 11:08:38
【问题描述】:

我正在尝试覆盖
app/design/frontend/base/default/template/contacts/form.phtml。

我遵循了几个指南但没有成功:
我只能发布一个链接,因为我没有足够的声誉来发布更多:( http://www.magento.scommerce-mage.co.uk/override-phtml-or-layout-core-files-in-magento.html

事实上,我现在更加困惑,因为他们都使用不同的方法。目前我正在尝试像上一个指南中那样做,因为这是迄今为止没有成功的最新版本(2014 年)。

这就是我得到的:
app/code/local/Namespace/MyModule/etc/config.xml

<config>
    <frontend>
        <layout>
            <updates>
                <contactredirect>
                    <file>contactredirect.xml</file>
                </contactredirect>
            </updates>
        </layout>
    </frontend>
</config>



app/design/frontend/base/default/layout/contactredirect.xml

<layout version="0.1.0">
    <contacts_index_index translate="label">
        <reference name="contacts.form">
            <action method="setTemplate">
                <template>contactredirect/form.phtml</template>
            </action>
        </reference>
    </contacts_index_index>
</layout>



最后是 my form.phtml 的位置(内容可能无关紧要):
app/design/frontend/base/default/template/contactredirect/form .phtml。

任何帮助表示赞赏!

【问题讨论】:

  • 您肯定知道每次更改布局 xml 文件时都必须清理布局缓存,每次更改任何 xml 配置文件时都必须清理配置缓存,对吧?

标签: html magento php


【解决方案1】:

在参考名称中使用“contactForm”,即代码应该是--

<reference name="contactForm">
            <action method="setTemplate">
                <template>contactredirect/form.phtml</template>
            </action>
        </reference>

【讨论】:

  • 感谢您的回答,但遗憾的是它对我没有用。我需要做更多的测试,希望这个周末,但可能在周一。您如何知道需要使用哪个参考名称?
  • 在布局文件 frontend/base/default/layout/contacts.xml 你会看到块定义为
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-11
  • 2012-02-18
  • 2012-07-14
  • 1970-01-01
相关资源
最近更新 更多