如何将项目添加到 magento 面包屑 [英] How to add an item to magento breadcrumbs

查看:30
本文介绍了如何将项目添加到 magento 面包屑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户在 magento 前端导航我自己的模块时显示面包屑,该站点已经有适当的面包屑代码,按照标准的 magento 面包屑在其他地方使用.

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?

我希望能够以编程方式执行此操作,而不必在面包屑 phtml 文件中编写自定义内容

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

推荐答案

您可以在 _prepareLayout 函数的自定义块文件中调用如下所示的面包屑.

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()));
            }

希望这对你有帮助.

这篇关于如何将项目添加到 magento 面包屑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆