事实上,您的 config.xml 文件中的节点并没有进行“更新”。
事实上,我认为你已经在 config.xml 中做到了:
<config>
<frontend>
<layout>
<updates>
<checkout>
<file>mylayout.xml</file>
</checkout>
</updates>
</layout>
</frontend>
</config>
您已经在 mylayout.xml 中进行了修改。
事实上,你必须这样做:
<config>
<frontend>
<layout>
<updates>
<mymodule>
<file>mylayout.xml</file>
</mymodule>
</updates>
</layout>
</frontend>
</config>
然后,在 mylayout.xml 中:
<checkout_cart_index> <!-- this corresponds to the section where you want to add your block (or modify an existing block -->
<reference name="content">
<reference name="checkout.cart">
<block type="mymodule/myblock" name="checkout.mymodule.myblock"></block>
</reference>
</reference>
</checkout_cart_index>
通过查看我的代码并将文件相互比较,您将更好地了解它的工作原理。
其实别忘了,所有的xml文件都是用magento拼接的。
这样,所有配置文件中的所有节点都将按照相同的顺序连接。
例如,在我们的例子中,magento 的 config.xml 文件将被连接起来,结果是 ONE 文件包含:
<config>
<!-- some nodes... -->
<!-- some nodes... -->
<!-- some nodes... -->
<frontend>
<layout>
<updates>
<mymodule>
<file>mylayout.xml</file>
</mymodule>
<checkout> <!-- this is the node from the config.xml of the Checkout Module-->
<file>checkout.xml</file>
</checkout>
<!-- some layout updates nodes from other config files... -->
</updates>
</layout>
</frontend>
<!-- some nodes... -->
<!-- some nodes... -->
</config>
如果您将<mymodule> 替换为<checkout>,则生成的文件看起来会是:
<config>
<!-- some nodes... -->
<!-- some nodes... -->
<!-- some nodes... -->
<frontend>
<layout>
<updates>
<checkout>
<file>mylayout.xml</file>
</checkout>
<!-- some layout updates nodes from other config files... -->
</updates>
</layout>
</frontend>
<!-- some nodes... -->
<!-- some nodes... -->
</config>
注意 mylayout.xml。
这就是为什么原来的布局文件被你自己的布局完全替代的原因:)
希望这很清楚,用法语解释会更容易;)
雨果。