Magento : Add custom breadcrumbs to any pages

1
16
views
Dear my friends,

Advertisement

Today I’ll write about the breadcrumbs. I’ll explain how to add breadcrumbs to your custom module (Due to default settings, your custom module doesn’t contain a breadcrumbs).
We will add links to breadcrumbs block of Magento.
Open the block that you want to add breadcrumbs then find function

public function _prepareLayout()

Then change it to:


public function _prepareLayout()
{
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); 
 $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 
 'title'=>Mage::helper('cms')->__('Home Page'), 'link'=>Mage::getBaseUrl())); 
 $breadcrumbs->addCrumb('an_alias', array('label'=>'Your label', 'title'=>'Your title', 
 'link'=>Mage::getUrl("your_module/your_block")));

return parent::_prepareLayout();
}

Refresh your page and you can see the breadcrumbs like this: home/your label 

Ok, we are done !!! Please leave your comments here. 🙂

I hope this helps someone 🙂

Thanx,
Mayank Zalavadia  🙂