B-219 Sec-55 Noida, India
+918010221733

Ways to Enable or Add Custom Breadcrumbs in Magento

There are some pages in Magento with no breadcrumbs enabled by default. In order to enable it, for example, on the checkout page, open checkout.xml file stored in ‘layout’ folder of the current theme, and find there ‘checkout_onepage_index’ block.  Then add to the block this code:
   
<reference name=”breadcrumbs”>
            <action method=”addCrumb”>
                <crumbName>Home</crumbName>
                <crumbInfo>
                    <label>Home</label>
                    <title>Home</title>
                    <link>/home</link>
                </crumbInfo>
            </action>
            <action method=”addCrumb”>
                <crumbName>Cart</crumbName>
                <crumbInfo>
                    <label>Cart</label>
                    <title>Cart</title>
                </crumbInfo>
            </action>
        </reference>

If the modified store is multilingual add into the opening tag of the block <translate=”label”>, here’s the example:
   
< checkout_onepage_index translate=”label”>

The content of ‘label’ tag and proper translation should be added to mage_checkout.csv file.

The above described example illustrates how to show breadcrumbs with the help of xml, but it is possible to do it directly in the code of the phtml files. With the help of the line (see the example below) it is possible to enable breadcrumbs and show it on a certain page:
   
echo $this->getLayout()->getBlock(‘breadcrumbs’)->toHtml();

This example describes a simple method how to add custom breadcrumbs:

// get breadcrumbs block
$breadcrumbs = $this->getLayout()->getBlock(‘breadcrumbs’);
// add first item with link
$breadcrumbs->addCrumb(
‘home’,
 array(
‘label’=>$this->__(‘Home’),
‘title’=>$this->__(‘Home’),
‘link’=>Mage::getBaseUrl()
)
);
// add second item without link
$breadcrumbs->addCrumb(
‘brands’,
 array(
‘label’=>$this->__(‘Brands’),
‘title’=>$this->__(‘Brands’)
)
);
echo $breadcrumbs->toHtml();

The advantage of this method is that you can dynamically modify breadcrumbs (if it’s necessary).

(Visited 81 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.