0

我在我的项目中使用 Meanbee Infinite Scroll模块。我让它适用于普通类别的产品列表。但现在我正试图在我的定制模块上激活它。

68但是我在以下方面感到困惑Script.php

 66       return (
 67           $block !== false &&
 68           $block->getChild('toolbar') !== false && // <-- This line
 69           $this->_getPagerBlock() !== false &&
 70           $this->_getPagerBlock()->getCollection()
 71       );

没有 xml 元素name具有toolbar. 即使在正常工作的类别 xml 中也是如此。那么指的是什么"toolbar"呢?

Avar_dump($block->getChild('toolbar'));在我的页面上返回 false,但在正常类别的产品列表页面上不返回。

我的 XML 如下(为了清楚起见):

        <block type="mynamespace/mymodule" name="mymodule.view" template="mynamespace/mymodule/view.phtml">
            <block type="catalog/product_list" name="product_list" template="toxicfox/giftfinder/list.phtml">
                <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                    <block type="page/html_pager" name="product_list_toolbar_pager"/>
                </block>
                <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
                <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
                <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
            </block>
        </block>    

核心 XML(与 Infinite Scroll 模块一起使用)是:

        <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
            <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                    <block type="page/html_pager" name="product_list_toolbar_pager"/>
                </block>
                <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
                <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
                <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
            </block>
        </block>

如您所见,两个 XML 块都没有任何属性name"toolbar". 唯一的区别是线1

任何帮助表示赞赏。

4

1 回答 1

0

在该Mage_Catalog_Block_Product_List::_beforeToHtml()方法中,工具栏块从布局中检索,其名称由setToolbarBlockName操作指示,然后设置为具有toolbar别名的产品列表的子块。

在您的情况下,问题可能是$block尚未输出toHtml(),因此它还不知道它的toolbar孩子,或类似的东西(很难说,因为扩展是商业的)。

于 2013-09-20T13:07:35.560 回答