为什么布局更新xml不添加我的块?

时间:2012-12-10 23:46:45

标签: magento layout

在我的一个类别页面上有一些布局xml,我无法让最后一行工作

<remove name="breadcrumbs" />

<reference name="head">
    <action method="addCss"><script>css/speakers.css</script></action>
</reference>

<block type="page/html" name="catalog.filter" before="product_list" template="catalog/category/filter.phtml" />

我正在尝试添加catalog/category/filter.phtml,但它无效。我已经检查了我的默认category.xml,以确保我在before中引用了正确的名称,但没有运气。

的catalog.xml:

<catalog_category_layered translate="label">
    <label>Catalog Category (Anchor)</label>
    <reference name="left">
        <block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/>
    </reference>
    <reference name="breadcrumbs.container">
        <block type="catalog/category_view" name="category.title" after="breadcrumbs" template="catalog/category/title.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>

1 个答案:

答案 0 :(得分:1)

我将假设您的布局块实际上看起来像这样

<catalog_category_view>
    <remove name="breadcrumbs" />

    <reference name="head">
        <action method="addCss"><script>css/speakers.css</script></action>
    </reference>

    <block type="page/html" name="catalog.filter" before="product_list" template="catalog/category/filter.phtml" />
</catalog_category_view>    

所以,虽然你的块的具体语法

<block type="page/html" name="catalog.filter" before="product_list" template="catalog/category/filter.phtml" />

可能没问题,因为你在catalog_category_view句柄下直接使用它,Magento不知道该块放在哪里。这意味着它要么忽略它,要么实例化块但不插入任何地方。