Mat*_*hew 6 php magento e-commerce web
我想显示面包屑,而一个用户在magento的前端导航我自己的模块,该网站已经有适当的面包屑代码,这些代码在其他地方用于标准的magento面包屑.
在模块中我需要做什么来指定当前的痕迹路径?
我更喜欢能够以编程方式执行此操作,而不必在breadcrumbs phtml文件中编写自定义内容
您也可以在任何自定义模块布局中从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...>
Run Code Online (Sandbox Code Playgroud)
您可以在_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()));
}
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助.