[英]I'm trying to display breadcrumbs on product page in magento but it gives me a fatal error
This is the line I have put in catalog/product/view.phtml: 这是我在catalog / product / view.phtml中输入的行:
<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>
And this is the error I get: 这是我得到的错误:
Fatal error: Call to a member function toHtml() on a non-object in ../catalog/product/view.phtml on line 159
Any solutions to this? 有什么解决办法吗? I am running Magento 1.4.1.1 我正在运行Magento 1.4.1.1
XML XML
Make sure you have your configuration setup in your theme's page.xml 确保在主题的page.xml中有配置设置
<block reference="header">
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</block>
View 视图
You need to call the HTML item itself 您需要调用HTML项本身
<?php echo $this->getChildHtml('breadcrumbs') ?>
I had this same quandary. 我有同样的困惑。 I managed to get breadcrumbs on the products page by adding the following to app/design/frontend/THEME/default/layout/calalog.xml 通过在app / design / frontend / THEME / default / layout / calalog.xml中添加以下内容,我设法在产品页面上获得了面包屑
<catalog_product_view translate="label">
<-- existing content -->
<reference name="content">
<-- existing blocks -->
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<-- existing blocks -->
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</block>
</reference>
<-- existing content -->
</catalog_product_view>
Then in catalog/product/view.phtml add the following where you would like the breadcrumbs to appear. 然后在catalog / product / view.phtml中添加以下内容,以显示面包屑。
<?php echo $this->getChildHtml('breadcrumbs') ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.