1

我正在尝试覆盖购物车页面中的运输块。但是,我的代码只是将运输文件复制了两次。奇怪的是它复制了我的运输文件两次,而不是一个。如何禁用原始 shipping.phtml 文件并使 magento 仅使用我的布局?

这是我的代码:

app/etc/modules/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
    <Module_Name>

        <!-- Whether our module is active: true or false -->
        <active>true</active>

        <!-- Which code pool to use: core, community or local -->
        <codePool>local</codePool>

    </Module_Name>
  </modules>
</config>

等/config.xml

<?xml version="1.0" encoding="UTF-8"?>

<!-- The root node for Magento module configuration -->
<config> 

<!-- 
    The module's node contains basic 
    information about each Magento module
-->
<modules>

    <!--
        This must exactly match the namespace and module's folder
        names, with directory separators replaced by underscores
    -->
    <Module_Name>

        <!-- The version of our module, starting at 0.0.1 -->
        <version>0.0.1</version>

    </Module_Name>

</modules>

<frontend>
    <layout>
        <updates>
            <brands>
                <file>shipping.xml</file>
            </brands>
        </updates>
    </layout>
</frontend>

</config>

我的主题布局 XML 文件:

<?xml version="1.0"?>

<layout version="0.1.0">

<!--
Default layout, loads most of the pages
-->

<checkout_cart_index translate="label">
    <label>Shopping Cart</label>
    <remove name="right"/>
    <remove name="left"/>
    <!-- Mage_Checkout -->
<reference name="head">
    <action method="addCss"><stylesheet>css/shipping.css</stylesheet>  </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>
            <action method="chooseTemplate"/>
            <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>
            <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/item/default.phtml</template></action>
            <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/item/default.phtml</template></action>

            <block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
                <label>Payment Methods Before Checkout Button</label>
                <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
            </block>

            <block type="page/html_wrapper" name="checkout.cart.form.before" as="form_before" translate="label">
                <label>Shopping Cart Form Before</label>
            </block>

            <block type="core/text_list" name="checkout.cart.methods" as="methods" translate="label">
                <label>Payment Methods After Checkout Button</label>
                <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
                <block type="checkout/multishipping_link" name="checkout.cart.methods.multishipping" template="checkout/multishipping/link.phtml"/>
            </block>

            <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
            <block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="module/shipping.phtml"/>
            <block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>

            <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
        </block>
    </reference>
    <block type="core/text_list" name="additional.product.info" translate="label">
        <label>Additional Product Info</label>
    </block>
 </checkout_cart_index>

</layout> 
4

2 回答 2

1

你不需要复制所有的布局代码。只需更改模板:

<reference name="checkout.cart.shipping">
    <action method="setTemplate"><template>path/to/template.phtml</template></action>
</reference>
于 2012-12-13T21:48:01.360 回答
0

这可能是由于

<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>
        <action method="chooseTemplate"/>
        <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>
        <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/item/default.phtml</template></action>
        <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/item/default.phtml</template></action>

        <block type="core/text_list" name="checkout.cart.top_methods" as="top_methods" translate="label">
            <label>Payment Methods Before Checkout Button</label>
            <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
        </block>

        <block type="page/html_wrapper" name="checkout.cart.form.before" as="form_before" translate="label">
            <label>Shopping Cart Form Before</label>
        </block>

        <block type="core/text_list" name="checkout.cart.methods" as="methods" translate="label">
            <label>Payment Methods After Checkout Button</label>
            <block type="checkout/onepage_link" name="checkout.cart.methods.onepage" template="checkout/onepage/link.phtml"/>
            <block type="checkout/multishipping_link" name="checkout.cart.methods.multishipping" template="checkout/multishipping/link.phtml"/>
        </block>

        <block type="checkout/cart_coupon" name="checkout.cart.coupon" as="coupon" template="checkout/cart/coupon.phtml"/>
        <block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="Beckin/dropdownshipping/drop_down_shipping.phtml"/>
        <block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>

        <block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
    </block>
</reference>

存在于 checkout.xml 中,现在您的运输模块布局(我猜 drop_down_shipping.xml)有一个句柄 checkout_cart_index,它的代码与它被调用两次的结果相同。

我建议在您的自定义模块布局中只更新您为处理程序所做的更改,而不是全部处理。

希望这有帮助。

于 2012-12-13T20:17:16.993 回答