Magento Breadcrumbs in phtml file

Photo of author
Written By Ryan Rana





Breadcrumbs in Magento. OK, first issue is that it’s not as obvious as it might seem – for a start a product can exist in more than one category, so for any given product URL there is no way to know which the ‘best’ or most appropriate breadcrumbs trail is.

There are a few great resources on it. First one is this thread – what a classic, some really great input from 3 or 4 developers here that will teach anyone reading it how to set up their own module.

Handy tip on it all the way from Kathmandu on the code to add to your template PHTML files;

To save you reading it, it’s this 😉 ;

<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>

You could also add breadcrumbs on a case by case basis by adding the public _prepareLayout() method to the relevant block, as per this thread;

What is being suggested here is that, say for the cart/basket page, you would create a local block app/code/local/Mage/Checkout/Block/Cart.php and include the method _prepareLayout().

Leave a Comment