使用local.xml将块添加到magento类别页面

时间:2014-04-24 06:21:50

标签: magento

在发布之前,我已查看以下内容,但所有这些都没有帮助我,我无法添加块。

magento - adding and positioning a block using local.xml

Magento - Add phtml file to layout block

Magento 1.7:Show category image on category page in full width in a 2 column template

我想在页面顶部添加类别图像。目前它显示在产品列表视图下,我希望它在左侧导航上方,以便它占用整页宽度。

我在 mytheme / template / catalog / category / image.phtml 中创建了一个模板文件,我刚刚添加了一些文字“我在这里”。

之后,我将以下xml添加到 catalog_category_default

下的local.xml文件中
<reference name="content">
    <block type="catalog/category_view" name="category.image" template="catalog/category/image.phtml"></block>
</reference>

但它仍然不起作用,并且文本不会显示在那里。当显示此文本时,我将显示类别图像,但是现在我只想使块工作并将其显示在页面顶部。

谢谢

1 个答案:

答案 0 :(得分:2)

也许您的类别不会加载布局句柄catalog_category_default。类别_default_layered有2个句柄 为了确保你能够覆盖这两种情况,所以你不会重复标记尝试这种方法 定义您的自定义句柄。

<my_awsome_category_handle>
    <reference name="content">
        <block type="catalog/category_view" name="category.image" template="catalog/category/image.phtml"></block>
    </reference>
</my_awsome_category_handle>

然后在两个类别句柄中包含该句柄。

<catalog_category_default>
    <update handle="my_awsome_category_handle" />
</catalog_category_default>
<catalog_category_layered>
    <update handle="my_awsome_category_handle" />
</catalog_category_layered>