How to add an item to magento breadcrumbs

大兔子大兔子 提交于 2019-11-29 20:57:55

问题


I want to display breadcrumbs while a use navigates my own module on the frontend of magento, the site already has the appropriate breadcrumb code in place thats used elsewhere as per standard magento breadcrumbs.

What do I need to do in my module to specify the current breadcrumb path?

I'd prefer to be able to do this programmatically rather than having to write something custom in the breadcrumbs phtml file


回答1:


you can call breadcrumbs like below in your custom block file in your _prepareLayout function.

if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
    $breadcrumbs->addCrumb('home', array('label'=>$helper->__('Home'), 'title'=>$helper->__('Go to Home Page'), 'link'=>Mage::getBaseUrl()));
    $breadcrumbs->addCrumb('product_list', array('label'=>$helper->__('Brands'), 'title'=>$helper->__('Brands'), 'link'=>Mage::getUrl('brands')));
    $breadcrumbs->addCrumb('product_detail', array('label'=>Mage::getModel('inic_brand/brand')->getBrandName($brand->getBrand(), Mage::app()->getStore()->getId()), 'title'=>$brand->getIdentifier()));
            }

hope this will be sure help to you.




回答2:


You can call breadcrumbs also from xml in any custom modules layout.

<index_index...>   
 <reference name="breadcrumbs">
            <action method="addCrumb">
                <crumbName>Home</crumbName>
                <crumbInfo>
                    <label>Home</label>
                    <title>Home</title>
                    <link>/</link>
                </crumbInfo>
            </action>
            <action method="addCrumb">
                <crumbName>Contacts</crumbName>
                <crumbInfo>
                    <label>Custom Page</label>
                    <title>Custom Page</title>
                </crumbInfo>
            </action>
        </reference>
</index_index...>


来源:https://stackoverflow.com/questions/18839151/how-to-add-an-item-to-magento-breadcrumbs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!