Magento-使用更新XML删除块 [英] Magento - remove block using update XML

查看:65
本文介绍了Magento-使用更新XML删除块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用布局xml文件删除现有的块?具体来说,我想从名为"top.switches"的块中删除名为"currency"的块.它将被插入到directory.xml文件中,如下所示:

How do I use a layout xml file to remove an already existing block? Specifically, I want to remove the block named "currency" from the block named "top.switches". It is being inserted in the directory.xml file, like this:

<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文件中定义的块:

There are two methods to remove a block defined in one layout xml file, through another xml file:

<default>
    <reference name="top.switches">
        <action method="unsetChild"><name>currency</name></action>
    </reference>
</default>

以及通常期望的操作方式:

And the way you are conventionally expected to do it:

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

您可以找到有关各种布局xml元素的说明 ,但这并不涵盖action标签可用的方法.为此,您需要查看块类app/code/core/Mage/Core/Block/Abstract.php,该类具有各种有用的功能,例如unsetChild,unsetCallChild,insert,sortChildren等.

You can find an explanation of the various layout xml elements here, but it doesn't cover the methods available to the action tag. For that, you need to look at the block class app/code/core/Mage/Core/Block/Abstract.php, which features all sorts of useful functions such as unsetChild, unsetCallChild, insert, sortChildren, etc.

这篇关于Magento-使用更新XML删除块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆