【发布时间】:2013-09-16 23:46:02
【问题描述】:
我想在用户在 magento 前端导航我自己的模块时显示面包屑,该网站已经有适当的面包屑代码,可以按照标准 magento 面包屑在其他地方使用。
我需要在我的模块中做什么来指定当前的面包屑路径?
我希望能够以编程方式执行此操作,而不必在面包屑 phtml 文件中编写自定义内容
【问题讨论】:
标签: php magento web e-commerce
我想在用户在 magento 前端导航我自己的模块时显示面包屑,该网站已经有适当的面包屑代码,可以按照标准 magento 面包屑在其他地方使用。
我需要在我的模块中做什么来指定当前的面包屑路径?
我希望能够以编程方式执行此操作,而不必在面包屑 phtml 文件中编写自定义内容
【问题讨论】:
标签: php magento web e-commerce
您也可以在任何自定义模块布局中从 xml 调用面包屑。
<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...>
【讨论】:
您可以在_prepareLayout 函数的自定义块文件中调用如下面包屑。
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()));
}
希望这对你有帮助。
【讨论】: