简体   繁体   English

尝试调用list.phtml文件中的分层导航块-Magento

[英]Trying to call layered nav block in the list.phtml file - Magento

By default in this theme the layered navigation is in the left column, and it is called in the 2columns-left.phtml 默认情况下,此主题中的分层导航位于左列,并在2columns-left.phtml中调用

<div class="col-left sidebar grid12-3 grid-col2-sidebar in-sidebar"><?php echo $this->getChildHtml('left') ?></div>

When I comment out the php there, it disappears, and if I move it around inside the 2columns-left.phtml file, layered nav moves. 当我注释掉那里的php时,它消失了,如果我在2columns-left.phtml文件内移动它,分层的nav移动。 However I would like to call this block from inside the list.phtml file instead, because I want layered nav to be contained in the category-products div. 但是,我想从list.phtml文件中调用此块,因为我希望将分层​​的nav包含在category-products div中。

When I put that php in the list.phtml file nothing happens. 当我将该php放入list.phtml文件中时,什么也没有发生。

I believe the issue is something to do with the catalog.xml file, but I'm not sure exactly how to modify it to get this block called in the file I want. 我相信这个问题与catalog.xml文件有关,但是我不确定究竟如何修改它才能在我想要的文件中调用此块。

Here is the code from where it's coming from in the catalog.xml file: 这是catalog.xml文件中来自其来源的代码:

<catalog_category_layered translate="label">
    <label>Catalog Category (Anchor)</label>
    <reference name="left">
        <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
    </reference>
    <reference name="content">
        <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">
                <!-- <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/su.phtml</template></action> -->
                <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"/>
                    <!-- The following code shows how to set your own pager increments -->
                    <!--
                        <action method="setDefaultListPerPage"><limit>4</limit></action>
                        <action method="setDefaultGridPerPage"><limit>3</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
                        <action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
                        <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>3</limit></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>6</limit></action>
                        <action method="addPagerLimit"><mode>grid</mode><limit>9</limit></action>
                        <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
                    -->
                </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>
    </reference>
</catalog_category_layered>

If anyone has any idea how I can modify that (or any other layout xml file) to be able to call the layered nav block from inside list.phtml that would be a great help. 如果有人知道如何修改(或任何其他布局xml文件)以能够从list.phtml内部调用分层的nav块,那将是一个很大的帮助。

Xander ,please try it call to proper place... Xander,请尝试将其拨到适当的位置...

<catalog_category_layered translate="label">
    <label>Catalog Category (Anchor)</label>
    <reference name="left">
    </reference>
    <reference name="content">
        <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/layer_view" name="catalog.leftnav"  template="catalog/layer/view.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>
    </reference>
</catalog_category_layered>


<catalog_category_default translate="label">
    <label>Catalog Category (Non-Anchor)</label>
    <reference name="content">
        <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/navigation" name="catalog.leftnav" template="catalog/navigation/left.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>
    </reference>
</catalog_category_default>

And also add the below code for call layernaviation on list page list.phtml 并在列表页面list.phtml上添加以下代码进行呼叫分层导航

<?php echo $this->getChildHtml('catalog.leftnav'); ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM