3

is there any way remove specific crumb from breadcrumbs ?

we can add crumb method addCrumb from Block Class Mage_Page_Block_Html_Breadcrumbs

but I didn't find any method to remove crumbs like removeCrumb like method which remove crumbs from bread crumbs from any position

1 Answer 1

3

To me, the only way you can do that is via a block rewrite by creating a module so in app/code/local/Vendor/Module/Block/Page/Html/Breadcrumbs.php:

<?php

class Vendor_Module_Block_Page_Html_Breadcrumbs extends Mage_Page_Block_Html_Breadcrumbs {

    public function removeCrumb($crumbName)
    {
        if (isset($this->_crumbs[$crumbName])) {
            unset($this->_crumbs[$crumbName]);
        }
    }
}

Then in app/code/local/Vendor/Module/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Vendor_Module>
            <version>0.0.1</version>
        </Vendor_Module>
    </modules>
    <global>
        <blocks>
            <page>
                <rewrite>
                    <!-- Mage_Page_Block_Html_Breadcrumbs -->
                    <html_breadcrumbs>Vendor_Module_Block_Page_Html_Breadcrumbs</html_breadcrumbs>
                </rewrite>
            </page>
        </blocks>
    </global>
</config>

And finally app/etc/modules/Vendor_Module.xml:

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

Then you should be able to do the following in your layout XML file:

<reference name="breadcrumbs">
    <action method="removeCrumb">
        <crumbName>Home</crumbName>
    </action>
</reference>

Replace Home with whatever crumb name you need to remove.

NB: actually I'm pretty sure it could be possible to do it via an event observer on controller_action_layout_generate_xml_before I'm just not 100% sure how to tacle this one.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.