I want to display the category breadcrumb in my custom modules product details page phtml file as:
Home/My Module/Category/Product name
In my
\app\design\frontend\base\default\template\magenshop\recipe\view.phtml
Is this the right way of adding in phtml file?
<?php $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
$breadcrumbs->addCrumb('home', array(
'label'=>Mage::helper('catalog')->__('Home'),
'title'=>Mage::helper('catalog')->__('Go to Home Page'),
'link'=>Mage::getBaseUrl()
));
$breadcrumbs->addCrumb('recipes', array(
'label'=>Mage::helper('catalog')->__('Recipes'),
'title'=>Mage::helper('catalog')->__('Go to Recipes Page'),
'link'=> Mage::getBaseUrl().'recipes/' // Module Url
));
$breadcrumbs->addCrumb('category', array(
'label'=>Mage::helper('catalog')->__($cat->getTitle()),
'title'=>Mage::helper('catalog')->__($cat->getTitle()),
'link'=> $CategoryUrl // Category Url
));
echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();
?>
I also added in my modules layout file as:
\app\design\frontend\base\default\layout\magenshop\recipe.xml
<reference name="root">
<action method="unsetChild"><alias>breadcrumbs</alias></action>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
<action method="addCrumb">
<crumbName>Home</crumbName>
<crumbInfo><label>Home</label><title>Home</title><link>/</link></crumbInfo>
</action>
<action method="addCrumb">
<crumbName>Parent Page</crumbName>
<crumbInfo><label>Parent Page</label><title>Parent Page</title><link>/Parent Page link</link></crumbInfo>
</action>
<action method="addCrumb">
<crumbName>Current Page</crumbName>
<crumbInfo><label>Current Page</label><title>Current Page</title></crumbInfo>
</action>
</block>
</reference>
But there is no output of any crumbs