Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable a remove statement from local.xml in Magento

Tags:

layout

magento

Is it possible to disable a <remove name="left"> statement defined in a default layout .xml file, from the local.xml file?

For example, in the checkout.xml in the <checkout_cart_index> section, the statement <remove name="left"/> is defined there, but can you disable that line from the local.xml file, so you still see the left menu on the checkout page?

like image 883
Pieter Hoste Avatar asked Dec 13 '10 09:12

Pieter Hoste


2 Answers

By default Magento doesn't provide an <unremove /> tag for local.xml. However, the Layout system contains the right events, such that you can implement this yourself. And by "yourself", I mean I've created an experimental extension that adds such a tag. Feedback is welcome.

like image 153
Alan Storm Avatar answered Oct 21 '22 10:10

Alan Storm


The two ways I do this are;

  1. Use Alan Storm's excellent unremove plugin above.

  2. Re insert the removed block in local.xml with a new name attribute but the same alias or 'as' attribute.

The name attribute needs to be different because Magento's <remove name="foo" /> is global - it removes all instances of <block name="foo" /> even if they are added after the remove instruction. To re add the left column, for example;

<reference name="root">
  <block name="left.2" as="left" type="core/text_list">
  <!-- New left column is empty, so you'll need to add your left-column blocks into it here. -->
  </block>
</reference>

name="left.2" means the remove action won't kill this block, as="left" means that it will still be inserted into your template via <?php echo $this->getChildHtml('left') ?>.

Unfortunately, your newly inserted left column is empty. So you'd have to re insert any blocks in there that you want to show as well. Making Alan Storm's plugin all the more useful, I think.

like image 44
0x00h Avatar answered Oct 21 '22 10:10

0x00h