![](/img/trans.png)
[英]error: I'm trying to display categories names from category table in product page dropdown, but displaying undefined variable, please help me out
[英]I'm trying to display breadcrumbs on product page in magento but it gives me a fatal error
這是我在catalog / product / view.phtml中輸入的行:
<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>
這是我得到的錯誤:
Fatal error: Call to a member function toHtml() on a non-object in ../catalog/product/view.phtml on line 159
有什么解決辦法嗎? 我正在運行Magento 1.4.1.1
XML
確保在主題的page.xml中有配置設置
<block reference="header">
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</block>
視圖
您需要調用HTML項本身
<?php echo $this->getChildHtml('breadcrumbs') ?>
我有同樣的困惑。 通過在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>
然后在catalog / product / view.phtml中添加以下內容,以顯示面包屑。
<?php echo $this->getChildHtml('breadcrumbs') ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.