PHP Magento Tips

Add Breadcrumbs to your Custom Module in Magento

Rate this posting:
{[['']]}

If you are creating a custom module in Magento with front end page, then this post will help you to create your breadcrumb for your custom page.

Method 1:

For front end check _prepareLayout() function inside your app/code/local/{namespace}/{modulename}/Block/{entity}.php

inside this function you can define your breadcrumb as per below:

protected 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'=>'My label', 'title'=>'My Title'));

      

         return parent::_prepareLayout();

    }

Method 2:

you can also add your custom breadcrumb code under your front end layout.xml file

In that file add below code:

<reference name="root">

   ------------------

   <action method="unsetChild">

    <alias>breadcrumbs</alias>

   </action>

   <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">

    <action method="addCrumb">

     <breadcrumbName>Home</breadcrumbName>

     <breadcrumbInfo>

      <label>Home</label>

      <title>Home</title>

      <link>/</link>

     </breadcrumbInfo>

    </action>

    <action method="addCrumb">

     <breadcrumbName>NEW PAGE NAME</breadcrumbName>

     <breadcrumbInfo>

      <label>NEW PAGE Label</label>

      <title>NEW PAGE Title</title>

     </breadcrumbInfo>

    </action>

   </block>

   ----------------------

</reference>
Tag : Magento
1 Comments On "Add Breadcrumbs to your Custom Module in Magento"

How To Get Products Breadcrumb Of Searched Products In PDP Page? https://magento.stackexchange.com/questions/178268/how-to-get-products-breadcrumb-of-searched-products-in-pdp-page

Back To Top