1

这是我在 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

4

2 回答 2

1

XML

确保您在主题的 page.xml 中进行了配置设置

<block reference="header">
   <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</block> 

看法

您需要调用 HTML 项目本身

<?php echo $this->getChildHtml('breadcrumbs') ?>
于 2013-01-08T14:20:54.630 回答
0

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

<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.

<?php echo $this->getChildHtml('breadcrumbs') ?>
于 2013-12-05T23:35:40.740 回答