繁体   English   中英

Magento-cart.phtml-覆盖问题

[英]Magento - cart.phtml - Override issue

我已经看到了几个有关如何覆盖cart.phtml的示例,但是它们似乎都无法在我的文件中工作。

我有一个主题:

  • 应用/设计/前端/默认/ ves_fashion /

该文件位于:

  • app / design / frontend / default / ves_fashion / template / checkout / cart.phtml

我在以下位置创建了cart.phtml:

  • 应用程序/设计/前端/默认/ ves_fashion /模板/customsite/checkout/cart.phtml

然后,我在以下位置检查了主题的layout.xml:

  • app / design / frontend / default / ves_fashion / layout / checkout.xml

并看到此:

<layout>
    <checkout_cart_index translate="label">
        <label>Shopping Cart</label>
        <remove name="right"/>
        <remove name="left"/>
        <!-- Mage_Checkout -->
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="checkout/cart" name="checkout.cart">
                <action method="setCartTemplate"><value>checkout/cart.phtml</value></action>
                <action method="setEmptyTemplate"><value>checkout/cart/noItems.phtml</value></action>
...

我知道我想用我自己的一个覆盖这个cart.phtml并执行以下操作:我在其中打开了local.xml

app / etc / local.xml

并插入:

 <layout>
        <checkout_cart_index translate="label">
            <reference name="content">
                <block type="checkout/cart" name="checkout.cart">
                    <action method="setCartTemplate"><value>customsite/checkout/cart.phtml</value></action>
                    <action method="setEmptyTemplate"><value>customsite/checkout/cart/noItems.phtml</value></action>
                </block>
            </reference>
        </checkout_cart_index>
    </layout>

但这是行不通的。 我现在需要做什么? app / etc /中的local.xml是正确的还是我必须在app / design / frontend / default / ves_fashion / layout / local.xml中使用那一个? 我也看到了一些例子 标签已被忽略,值Tag被命名 并将内容设置为checkout.cart-如果原始xml文件说一些不同的内容,为什么要这样做?

如果有人可以在这里帮助我,那就太好了。 谢谢!

app/etc/local.xml文件不是您想要的。 其中包含您网站的环境信息。

您可以随意直接在主题的布局文件中进行更改:

app/design/frontend/default/ves_fashion/layout/checkout.xml

或者,您可以根据local.xml在该文件夹中添加local.xml ,并在那里进行布局更新。

正如其他人指出的那样,将布局句柄添加到app/etc/local.xml文件是错误的。 那只是为了配置。 您的主题应在app/design/frontend/{your-package-name}/{your-theme-variation-name}/layout/local.xml定义其自己的local.xml文件,或者您的模块应定义其自己的布局句柄在app/design/frontend/base/default/layout/{your-namespace}_{your-module}.xml

但是,在撰写本文时,问题中提供的布局XML存在一个固有的问题。 照原样,这些布局定义将不起作用。 调用setCartTemplatesetEmptyTemplate是正确的,但如果没有必须在它们之后直接调用的基本方法调用,它们将无法工作: chooseTemplate 如果您查看app/design/frontend/base/default/layout/checkout.xml文件,则可以在前两个之后直接看到该方法。 修改Magento购物车模板时,仅此方法调用已成为许多人感到沮丧的根源,有关该问题的StackOverflow问题数量显而易见。 我在这里写了对此问题的详尽解释: https : //stackoverflow.com/a/33875491/2973534

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM