设置“列表/网格"类别视图的 catalog.xml 中的默认视图模式 [英] Set "List / Grid" default view mode in catalog.xml for category view

查看:19
本文介绍了设置“列表/网格"类别视图的 catalog.xml 中的默认视图模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的类别视图默认以列表或网格模式显示产品.

I'm trying to do my category view display products in list or grid mode as default.

<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/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>9</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>
                    -->
                </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>

这是我在 中的代码.知道怎么做吗?我在谷歌上搜索了很多时间,但没有找到解决方案.

Here is the code that I have inside <catalog_category_layered> and in <catalog_category_default>. Know anyone how to do it? I was googling to much time and didn't found a solution.

推荐答案

您可以在布局 XML 或管理员的自定义布局更新"部分中使用以下 xml 执行此操作:

You can do this in the layout XML or the "Custom Layout Update" section in admin with the following xml:

<reference name="product_list_toolbar">
    <action method="setData"><key>_current_grid_mode</key><value>list</value></action>
</reference>

请确保,工具栏块名称在产品列表块中设置如下:

Be sure, the toolbar block name was set in the product list block like this:

<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>

这篇关于设置“列表/网格"类别视图的 catalog.xml 中的默认视图模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆