Magento Breadcrumbs in phtml file

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.

http://www.magentocommerce.com/boards/viewthread/176389/

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

http://blog.chapagain.com.np/magento-easily-add-breadcrumbs-to-any-page/

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;

http://www.magentocommerce.com/answers/discussion/1779/How-to-add-breadcrumbs-to-my-cart-page/p1

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