Magento – 使用更新XML删除块

如何使用布局xml文件删除已有的块?具体来说,我想从名为“top.switches”的块中删除名为“货币”的块.它正被插入到directory.xml文件中,如下所示:
<default>
    <reference name="top.switches">
        <block type="directory/currency" name="currency" before="store_language" template="directory/currency.phtml"/>
    </reference>
    <reference name="head">
        <block type="core/template" name="optional_zip_countries" as="optional_zip_countries" template="directory/js/optional_zip_countries.phtml" />
    </reference>
</default>
通过另一个xml文件,可以通过两种方法来删除在一个布局xml文件中定义的块:
<default>
    <reference name="top.switches">
        <action method="unsetChild"><name>currency</name></action>
    </reference>
</default>

而且你通常希望这样做的方式:

<default>
    <reference name="top.switches">
        <remove name="currency" />
    </reference>
</default>

您可以找到各种布局xml元素here的说明,但不包括可用于操作标签的方法.为此,您需要查看块类app / code / core / Mage / Core / Block / Abstract.php,它们具有各种有用的功能,如unsetChild,unsetCallChild,insert,sortChildren等.

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念