【问题标题】:How do I override the review tab on OnePage Checkout如何覆盖 OnePage Checkout 上的评论选项卡
【发布时间】:2012-06-12 15:54:57
【问题描述】:

我正在编写一个自定义模块来更改表在 checkout/onepage/onepage.phtml 上的显示,我可以在 checkout.xml 中看到它是如何声明的

<block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="checkout/onepage/review.phtml">
     <block type="checkout/agreements" name="checkout.onepage.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
</block>

我想不通的是如何设置 /app/design/frontend/{location}/{theme}/layout/{module}.xml 文件以用新模板覆盖当前的 review.phtml 模板.我的想法是删除当前的并重新加载新的,但这似乎不起作用。

【问题讨论】:

    标签: magento


    【解决方案1】:

    我首先看到的是您使用的目录不正确。

    应该是

    app/design/frontend/{location}/{theme}/layout/{module}.xml 
    

    而不是

    app/layout/frontend/{location}/{theme}/layout/{module}.xml 
    

    另外,我不确定您要如何覆盖审阅布局表,但以下内容将用您自己的审阅模板替换:

    <checkout_onepage_review>
        <reference name="root">
           <action method="setTemplate"><template>checkout/onepage/your_template.phtml</template></action>
        </reference>
    </checkout_onepage_review>
    

    其次,如果您正在创建自定义模块并希望加载布局文件,则必须在模块 config.xml 中声明布局更新。你这样做了吗?

    它看起来类似于:

    <?xml version="1.0"?>
    
    <config>
        <modules>
            <Your_Company_Your_Module>
                <version>1.0.0</version>
            </Your_Company_Your_Module>
        </modules>
        <frontend>
            <layout>
                <updates>
                    <yourmodule>
                        <file>yourmodule.xml</file>
                    </yourmodule>
                </updates>
            </layout>
        </frontend>
    </config>
    

    最后,根据您要实现的目标,您可能不需要一个模块来覆盖结帐审查表。

    如果模块的唯一目的是简单地覆盖结帐布局,那么使用以下方法之一覆盖布局可能就足够了:

    1. 使用local.xml

      在你的主题布局目录中创建一个 local.xml 文件:

      /app/design/frontend/{location}/{theme}/layout/{module}.xml

      并将其用于所有核心布局覆盖。这有很多好处。

    2. 将基本 checkout.xml 布局文件复制到您的主题

      复制 app/design/frontend/base/default/layout/checkout.xml 到 app/design/frontend/{location}/{theme}/layout/checkout.xml

    【讨论】:

    • 仅供参考,由于您提到的目录问题,我解决了这个问题。当我使用 setTemplate 调用时,页面仍然继续加载原始表。我的想法是这种情况正在发生,因为 .phtml 仍然需要在 checkout/onepage/review 中,系统才能看到它。但是,我希望它存在于模块中,因为我需要调用将更改显示输出的特定类。该模块所做的不仅仅是改变桌子,但那部分是我所坚持的。它正在加载模块的 XML,只是不切换模板。
    • @GregDemetrick - 只是说,你的路径仍然是错误的,我假设它只是一个错字:) 你清除缓存了吗?另外,您可以发布您的 config.xml 和 layout.xml 文件吗?
    • 我认为我的解决方案是magentocommerce.com/wiki/4_-themes_and_template_customization/0-_theming_in_magento/how_to_customize_frontend_template_f.e._review.phtml_of_onepage_checkout 我正在更改模板名称而不更改块类型。现在尝试一下。
    猜你喜欢
    • 2013-04-30
    • 1970-01-01
    • 2012-11-20
    • 2016-02-02
    • 2015-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-04
    • 1970-01-01
    相关资源
    最近更新 更多