Magento - Add breadcrumbs in pages where magento do not provide them

Add in the bottom of your breadcrumbs.phtml file

<?php if(!$crumbs): ?>
<?php 
$urlRequest = Mage::app()->getFrontController()->getRequest();

$urlPart =  $urlRequest->getOriginalPathInfo();
if(is_null($urlPart))
{
    $urlPart = $urlRequest->getPathInfo();
}

$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);
 
$controllerName = str_replace("/", " ", $urlPart);
$controllerName = str_replace("_", " ", $controllerName);
$controllerName = str_replace("-", " ", $controllerName);
$controllerName = ucfirst($controllerName);

// Put title if nothing found in url (i.e Home page)
$title_prefix = Mage::getStoreConfig('design/head/title_prefix');
if(empty($controllerName)) {
    $controllerName = str_replace($title_prefix,'', $this->getLayout()->getBlock('head')->getTitle());
}

?>
<div class="breadcrumbs">
<ul>
    <li class="home">
        <a title="<?php echo $this->__('Go to Home Page') ?>" href="<?php echo $this->getUrl() ?>"><?php echo $this->__('Home') ?></a>
    </li>
    <li> / </li>
    <li>
        <strong><?php echo $this->__($controllerName) ?></strong>
    </li>
</ul>
</div>
<?php endif; ?>

No comments:

Post a Comment