Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento local.xml layout file - overriding <remove name="left"/>

Tags:

magento

Is there any way to override, or re-add something that was removed via it's xml layout, using local.xml?

I've made a theme that's all based on one page layout, 2columns-left. But a lot of pages, such as the sitemap, are set 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 template to use by adding:

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

So it's now showing the sitemap in a 2column left layout. But there's nothing in the left column, as the < remove name="left" /> has removed it. I hate that I have to override this whole catalog.xml just to remove that, as it's a pain then when they update to a new version, I need to update all these extra layout files too.

So, is there any way to fix that using my local.xml? I think for the default Magento themes, they should have everything set to use the 3column layout, as that way you're free to remove whatever you don't need, but it's all there by default, so all changes can be done in the local.xml file.

like image 652
Marlon Creative Avatar asked Dec 01 '22 04:12

Marlon Creative


1 Answers

Out of the box there's no way to unremove a layout block that's been removed by a previous call to <remove />. '

However, there's enough eventing in the Layout system that you can implement this yourself. And by "yourself", I mean I've created an experimental extension that adds a <unremove /> tag to the XML Layout system's grammer.

like image 59
Alan Storm Avatar answered Dec 05 '22 20:12

Alan Storm