Question

I have a layout defined in some xml file found in a community module. Somehow I want to add a condition (ifconfig) by which the content of the block to be rendered or completely remove that handle and create one by myself so that I can have access to the block.

To be more specific, this is the handle I have in udprod.xml

    <_udprod_catalog_product_edit>
        <reference name="content">
            <block type="core/template" template="udprod/product_edit.phtml" />
        </reference>
    </_udprod_catalog_product_edit>
    <adminhtml_catalog_product_edit>
        <update handle="_udprod_catalog_product_edit" />
    </adminhtml_catalog_product_edit>

As you can see, the block has no name I can rely on. Is there any way I can remove the <_udprod_catalog_product_edit> handle from an xml file?

Thank you

Was it helpful?

Solution

I am not sure that is possible, but I have a work around which I use to fix buggy 3rd party extensions:

Create a new module

A very simple one, only 2 files are required.

app/etc/modules/Namespace_Fixer.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Fixer>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Broken_Module/>
            </depends>
        </Namespace_Fixer>
    </modules>
</config>

Note the depends, this is very important so that it is loaded after.

app/code/local/Namespace/Fixer/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Namespace_Fixer>
            <version>0.1.0</version>
        </Namespace_Fixer>
    </modules>
    <global>
    </global>
    <frontend>
        <layout>
            <updates>
                <broken_module> <!-- update this -->
                    <file>namespace/module_fixed.xml</file>
                </broken_module>
            </updates>
        </layout>
    </frontend>
</config>

Override the layout file to point to our new one.

Duplicate the layout XML

You want to point at the new XML, in there you can do the right thing and add a name to the block and call it where ever you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top