Consider i have three blocks on left sidebar namely block_1
, block_2
and block_3
i can remove all of the above block by using below code
<remove name="block_1" />
<remove name="block_2" />
<remove name="block_3" />
but i dont want to use above code as blocks in my sidebar are coming dynamically. so i am looking for code which will remove all the block, something like <remove name="all" />
Best Answer
Via layout XML (although this will remove the whole block including the container):
Programmatically: In your
config.xml
, listen to the eventcore_block_abstract_to_html_before
(this will keep the container, but will remove all child blocks):And then in your
Observer.php
, unset all children if the current block is the block of the left sidebar: