2

ファイル checkout.xml の一部のみを変更したい (このファイルはコアのレイアウト フォルダーにあります)。独自の拡張機能を作成し、config.xml で独自の layout-xml-File にリンクします。

<layout>

  <updates>
    <checkout>
     <file>mymodule_checkout.xml</file>
    </checkout>
  </updates>
</layout>

ファイルcheckout.xml全体をコピーしてmymodule_checkout.xmlとして保存しても問題ありません。しかし、この大きなファイルのほんの一部をオーバーライドしたいだけです

<reference name="content">

</reference>

この場合、必要な部分のみを書き込むと、magento はこの部分を含むファイルのみを読み取ります。そのため、magento は元の checkout.xml の残りの部分を取得しません。

ファイル全体をコピーしたり、コアを変更したりせずに、コア レイアウト xml ファイルの一部のみを変更することは可能ですか。

mymodule.xml のコードは次のようになります。

<layout version="0.1.0">

<checkout_onepage_index translate="label">

    <reference name="content">
        <block type="checkout/onepage" name="checkout.onepage" template="checkout/onepage.phtml">
            <block type="checkout/onepage_login" name="checkout.onepage.login" as="login" template="checkout/onepage/login.phtml">
                <block type="page/html_wrapper" name="checkout.onepage.login.before" as="login_before" translate="label">
                    <label>Login/Registration Before</label>
                    <action method="setMayBeInvisible">
                        <value>1</value>
                    </action>
                </block>
                <block type="checkout/onepage_billing" name="checkout.onepage.billing" as="billing" template="checkout/onepage/billing.phtml"/>
                <block type="checkout/onepage_shipping" name="checkout.onepage.shipping" as="shipping" template="checkout/onepage/shipping.phtml"/>
            </block>
            <block type="checkout/onepage_shipping_method" name="checkout.onepage.shipping_method" as="shipping_method" template="checkout/onepage/shipping_method.phtml">
                <block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="checkout/onepage/shipping_method/available.phtml"/>
                <block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
            </block>
            <block type="checkout/onepage_payment" name="checkout.onepage.payment" as="payment" template="checkout/onepage/payment.phtml">
                <block type="checkout/onepage_payment_methods" name="checkout.payment.methods" as="methods" template="checkout/onepage/payment/methods.phtml">
                    <action method="setMethodFormTemplate">
                        <method>purchaseorder</method>
                        <template>payment/form/purchaseorder.phtml</template>
                    </action>
                </block>
            </block>
            <block type="checkout/onepage_review" name="checkout.onepage.review" as="review" template="checkout/onepage/review.phtml"/>
        </block>
    </reference>
</checkout_onepage_index>
</layout>

それが私が必要とする部分です。この場合、magento は、コア xml ファイルの残りのコードではなく、このコードのみを取得します。

4

1 に答える 1

0

はいぜったいに。Magento は、フォールバック テーマのファイルを含め、すべてのレイアウト ファイルを 1 つに結合します。すべてのファイルが処理された後も関連するものはすべて、レイアウトを生成するために使用され、xml が正しくフォーマットされている限り、任意の .xml ファイルのセクションをオーバーライドできます。 foob​​arbaz.xml でオーバーライドできないことを意味します。

あなたの問題はあなたの XML にある可能性が高いです。内容を投稿して、mymodule_checkout.xmlあなたが何をしようとしているのかを理解し、できれば機能する代替品を提供できますか?

于 2012-05-04T13:38:53.090 に答える