如何在magento CMS homepage 加上breadcrumbs

來源:互聯網
上載者:User
如何在magento CMS homepage 加上breadcrumbs2009-10-26 11:47

開啟 code/core/Mage/Cms/Block/Page.php,找到以下代碼,加上else後面的代碼即可

// show breadcrumbs 
if (Mage::getStoreConfig(’web/default/show_cms_breadcrumbs’) 
&& ($breadcrumbs = $this->getLayout()->getBlock(’breadcrumbs’)) 
&& ($page->getIdentifier()!==Mage::getStoreConfig(’web/default/cms_home_page’)) 
&& ($page->getIdentifier()!==Mage::getStoreConfig(’web/default/cms_no_route’))) { 
$breadcrumbs->addCrumb(’home’, array(’label’=>Mage::helper(’cms’)->__(’Home’), ‘title’=>Mage::helper(’cms’)->__(’Go to Home Page’), ‘link’=>Mage::getBaseUrl())); 
$breadcrumbs->addCrumb(’cms_page’, array(’label’=>$page->getTitle(), ‘title’=>$page->getTitle())); 
} else {$breadcrumbs->addCrumb(’home’, array(’label’=>Mage::helper(’cms’)->__(’Home’), ‘title’=>Mage::helper(’cms’)->__(’Go to Home Page’), ‘link’=>Mage::getBaseUrl())); 
$breadcrumbs->addCrumb(’cms_page’, array(’label’=>$page->getTitle(), ‘title’=>$page->getTitle())); 
}

 

如果想在預設沒有breadcrumbs的頁面顯示breadcrumbs,開啟breadcrumbs.phtml加入以下代碼:

<?php
/**
*
* CUSTOM BREADCRUMBS
* by magentoex.com
*
* Adds url breadcrumbs for pages that do not have breadcrumbs by default
*
*/?>
<?php if(is_null($crumbs)): ?>
<?php/**
* NOTE
* On some servers use ->getServer('PATH_INFO')
* and on some ->getServer('ORIG_PATH_INFO')
*/$urlRequest = Mage::app()->getFrontController()->getRequest();
$urlPart = $urlRequest->getServer('ORIG_PATH_INFO');if(is_null($urlPart))
{
    $urlPart = $urlRequest->getServer('PATH_INFO');
}$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);$controllerName = Mage::app()->getFrontController()->getRequest()->getControllerName();
$controllerName = ucfirst($controllerName);$controllerName = str_replace("/", " ", $urlPart);
$controllerName = str_replace("_", " ", $controllerName);
$controllerName = str_replace("-", " ", $controllerName);
$controllerName = ucfirst($controllerName);?><strong class="no-display"><?php echo $this->__("You're currently on: ") ?></strong>
<ul class="breadcrumbs">
<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 class="<?php echo strtolower($controllerName) ?>">
        <strong><?php echo $this->__($controllerName) ?></strong>
    </li>
</ul><?php endif; /* END OF CUSTOM BREADCRUMBS */ ?>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.