How to Display Breadcrumbs on a Custom PHTML Page in Magento 1.9

breadcrumbslocal.xmlmagento-1.9phtml

I try to display my breadcrumbs on a custom phtml file.

In a custom controller I have defined an indexAction. After calling http://my-shop.com/auctionlist my page is displayed.

Controller:

class MyNamespace_AuctionExtend_IndexController extends Mage_Core_Controller_Front_Action {
    public function indexAction() {
        $this->loadLayout();
        $block = $this->getLayout()->createBlock(
            'Mage_Core_Block_Template',
            'auctionlist',
            array('template' => 'auctionlist/auctionlist.phtml')
        );

        $this->getLayout()->getBlock('root')->setTemplate('page/2columns-right.phtml');
        $this->getLayout()->getBlock('content')->setTitle(Mage::helper('core')->__('Auktionsliste'))->append($block);
        $this->getLayout()->getBlock('head')->setTitle(Mage::helper('core')->__('Auktionsliste'));
        $this->_initLayoutMessages('core/session');
        $this->renderLayout();
    }
}

In my local.xml file I manage all breadcrumb definitions like:

<customer_account_login>
    <reference name="breadcrumbs">
        <action method="addCrumb">
            <crumbName>Home</crumbName>
            <crumbInfo>
                <label>Home</label>
                <title>Home</title>
                <link>/</link>
            </crumbInfo>
        </action>
    </reference>
</customer_account_login>

How can I call my custom auctionlist file in the local.xml to display the breadcrumbs? This is what I try to get:

<auctionlist_index>
    <reference name="breadcrumbs">
        <action method="addCrumb">
            ...
        </action>
    </reference>
</auctionlist_index>

(I already tryed that but it doesnt work.)

Best Answer

You can set this from your controller action. Below is the reference code.

public function IndexAction() {      
  $this->loadLayout();
  $this->getLayout()->getBlock("head")->setTitle($this->__("Auktionsliste"));
        $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
  $breadcrumbs->addCrumb("home", array(
            "label" => $this->__("Home Page"),
            "title" => $this->__("Home Page"),
            "link"  => Mage::getBaseUrl()
       ));

  $breadcrumbs->addCrumb("Auktionsliste", array(
            "label" => $this->__("Auktionsliste"),
            "title" => $this->__("Auktionsliste")
       ));

  $this->renderLayout(); 

}
Related Topic