Magento - remove block using update XML

前端 未结 2 765
臣服心动
臣服心动 2021-02-12 10:53

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 bein

相关标签:
2条回答
  • 2021-02-12 11:19

    add file named local.xml in your layout directory . then in local.xml you can remove any block with "remove" tag . BTW the remove tag should be between "layout" and "default" then the file should be :

    <?xml version="1.0" encoding="UTF-8"?>
    <layout>
       <default>
         <remove name="BLOCK_NAME" />
      </default>
    </layout>
    
    0 讨论(0)
  • 2021-02-12 11:29

    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>
    

    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.

    0 讨论(0)
提交回复
热议问题