Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 2
How to change breadcrumb according to our needs? 
 
Michael Baker
Jr. Member
 
Total Posts:  11
Joined:  2010-08-15
 
AndrewBessa - 24 August 2011 09:13 AM

You can also add breadcrumbs by making an XML update:

<reference name="breadcrumbs">
    <
action method="addCrumb">
        <
crumbName>New Crumb</crumbName>
        <
crumbInfo>
            <
label>New Crumb</label>
            <
title>New Crumb</title>
            <
link>somewhere.html</link>
        </
crumbInfo>
    </
action>
</
reference>

The above code will only append a breadcrumb to the end… to put the breadcrumb were you want, you can use (notice the “after” clause):
<reference name="breadcrumbs">
    <
action method="addCrumb">
        <
crumbName>NewCrumb</crumbName>
        <
crumbInfo>
            <
label>NewCrumb</label>
            <
title>My New Crumb</title>
            <
link>somewhere.html</link>
        </
crumbInfo>
        <
after>home</after>
    </
action>
</
reference>

However, the above code will only work if you update the addCrumb method. The original addCrumb method doesn’t support the “after” claus.  The new method I wrote below will support <after></after> in the XML and place the breadcrumb accordingly. Just use the “crumbName” in the <after></after> XML data.  For example, the crumbName for the home page is “home”
app/code/code/Mage/Page/Block/Html/Breadcrumbs.php - line 59
Update the method to this:
function addCrumb($crumbName$crumbInfo$after false)
    
{
        
if($after !== false && is_array($this->_crumbs)) {
            $crumbs 
$this->_crumbs;
            
$this->_crumbs = array();
            foreach(
$crumbs as $_crumbName => $_crumb{
                $this
->_crumbs[$_crumbName] $_crumb;
                if(
$after == $_crumbName{
                    $this
->_prepareArray($crumbInfo, array('label''title''link''first''last''readonly'));
                    if ((!isset(
$this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
                       $this
->_crumbs[$crumbName] $crumbInfo;
                    
}
                }
            }
        } 
else {
            $this
->_prepareArray($crumbInfo, array('label''title''link''first''last''readonly'));
            if ((!isset(
$this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
               $this
->_crumbs[$crumbName] $crumbInfo;
            
}
        }
        
return $this;
    
}

Worked like a charm. Thanks a alot!!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 2