Is there a way to override or re-add something that was deleted using the xml l...">

Magento local.xml layout file - override <delete name = "left" / ">

Is there a way to override or re-add something that was deleted using the xml layout using local.xml?

I created a theme based on one page layout, 2columns-left. But many pages, such as sitemap, are configured to use a 1column layout. So, for example, in catalog.xml we have:

 <catalog_seo_sitemap translate="label"> <label>Catalog Seo Sitemap (Common)</label> <remove name="right"/> <remove name="left"/> <reference name="root"> <action method="setTemplate"><template>page/1column.phtml</template></action> </reference> <reference name="content"> <block type="page/template_container" name="seo.sitemap.container" template="catalog/seo/sitemap/container.phtml"> <block type="page/template_links" name="seo.sitemap.links" as="links" template="page/template/links.phtml"/> <block type="page/html_pager" name="seo.sitemap.pager.top" as="pager_top" template="page/html/pager.phtml"/> <block type="page/html_pager" name="seo.sitemap.pager.bottom" as="pager_bottom" template="page/html/pager.phtml"/> </block> </reference> </catalog_seo_sitemap> 

And in my local.xml, I can override the root pattern by adding:

 <catalog_seo_sitemap> <reference name="root"> <action method="setTemplate"><template>page/2columns-left.phtml</template></action> </reference> </catalog_seo_sitemap> 

So now it displays the sitemap in the layout to the left of 2column. But there is nothing in the left column because <remove name = "left" / "> deleted it. I hate that I need to redefine this whole catalog.xml file to remove it, since it is pain when I upgrade to a new version You also need to update all of these additional layout files.

So, is there a way to fix this using my local.xml? I think that for Magento templates by default, they should have everything to use the 3column layout, since you can delete everything that you do not need, but it is all by default, so all changes can be made to the local.xml file.

+4
source share
3 answers

Out of the box, you cannot cancel the layout block that was removed by the previous <remove /> call.

However, the layout system has enough events that you can implement yourself. And "on my own," I mean, I created an experimental extension that adds the <unremove /> to the grammar module of the XML layout system.

+14
source

This was asked before , but no conclusion was reached . You can create a replacement block in your local.xml, but there is no guarantee that the child blocks added to it will be executed after your local changes.

 <catalog_seo_sitemap> <reference name="root"> <action method="setTemplate"><template>page/2columns-left.phtml</template></action> <block type="core/text_list" name="left" as="left" translate="label"> <label>Left Column</label> </block> <!-- Copied from page.xml --> <block type="core/text_list" name="right" as="right" translate="label"> <label>Right Column</label> </block> <!-- Copied from page.xml --> </reference> </catalog_seo_sitemap> 
+5
source

I managed to do this by simply changing the name of the block when reading it. It seems that if you delete a block and add it again with the same name, the remove label will apply to all blocks with the same name. In my case, he deleted the account navigation and added it to the header.

 <remove name="customer_account_navigation" /> <block type="customer/account_navigation" name="customer_account_nav" as="accountNavigation" template="customer/account/navigation.phtml"> 
0
source

Source: https://habr.com/ru/post/1333802/


All Articles