Breadcrumbs are very useful for user navigation. Breadcrumbs for product page, category page, etc. are created by default Magento code.
?
The following code will show breadcrumbs created by Magento. You can print the following code anywhere in php or phtml files.
echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();?
You can create you own breadcrumbs as well. Like, you may need to create breadcrumbs if you have your own custom built module. I will show you here, how you can do it.
?
It’s simple and easy. At first, you will define the breadcrumbs block. Then, you will add label, title and link to your breadcrumbs. The addCrumb Magento function is used in this case.
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Home Page'), 'link'=>Mage::getBaseUrl())); $breadcrumbs->addCrumb('country', array('label'=>'Country', 'title'=>'All Countries', 'link'=>'http://example.com/magento/moduleName/country')); $breadcrumbs->addCrumb('manufacturer', array('label'=>'State', 'title'=>'States')); echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();?
The label, title and link can be changed according to your need and requirement.
Hope this helps. Thanks.
?
來源: http://blog.chapagain.com.np/magento-easily-add-breadcrumbs-to-any-page/
?
?
Magento產品頁面的面包屑導航很怪異:如果從Category產品列表中進入Product,則面包屑導航中含有Category Path; 否則,當從首頁,或搜索結果中,或者其他什么地方進入,則缺少之。我想,可能是Magento支持一個產品放入多個Category的緣故吧。不管怎么 樣,產品頁中缺少了Category Path,用戶體驗不大好。如下:
?

?
修正的方法,找到文件
app/code/core/Mage/Catalog/Helper/Data.php
?
復制一份到local代碼池
app/code/local/Mage/Catalog/Helper/Data.php
?
在函數getBreadcrumbPath的開始部分,加上如下的代碼邏輯:
/** * Return current category path or get it from current category * and creating array of categories|product paths for breadcrumbs * * @return string */ public function getBreadcrumbPath() { // added by p.c.w.l 20110603 if ($this->getProduct() && !$this->getCategory()) { $_categoryIds = $this->getProduct()->getCategoryIds(); if ($_categoryId = $_categoryIds[0]) { $_category = Mage::getModel('catalog/category')->load($_categoryId); Mage::register('current_category', $_category); } } // ...?
首先判斷當前是否是產品頁,如果是并且沒有Category信息,就獲取產品所屬的Category IDs, Magento 中一個產品可以加入多個Category中,但不管三七二十一只挑出其中一個幸運的Category作為current_category。看最終的效果:

?
?
來源: http://www.sqlstudy.com/article/magento-product-page-breadcrumb-add-category-path.html
?
Magento產品頁面包屑導航(Breadcrumb)修正 Showing Breadcrumbs Anywhere in Magento
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
