我在所有类别页面上都有一个小部件设置 后端 - > CMS->小部件

现在,当我使用此方法时,我选择一个类别页面的块,并且块显示得很好。它位于左列中所有其他信息的底部。

但是如何将块移至顶部? (上面分层等)...

替代方法是使用 local.xml, ,我不喜欢 +它也出现在我使用相同主题的所有网站上。

有帮助吗?

解决方案

问题是Magento在左列的顶部没有窗口基容器。您可以分两个步骤创建这样的容器:

  1. 创建您的小部件块容器 local.xml 文件:

    <layout>
       <!-- category pages with layered navigation -->
       <catalog_category_layered>
            <update handle="custom_top_container" />
       </catalog_category_layered>
       <!-- category pages without layered navigation -->
       <catalog_category_default>
            <update handle="custom_top_container" />
       </catalog_category_default>
       <!-- custom block container on that page -->
       <custom_top_container>
            <reference name="left">
               <block name="left_top" type="core/text_list" before="-" translate="label">
                    <label>Left Column Top</label>
               </block>
            <reference>
       </custom_top_container>
    </layout>
    

    在下面的示例中 catalog_category_defaultcatalog_category_layered 是类别页面和 custom_top_container 手柄包含在这些页面中 更新 布局说明。新的 left_top 块是 mage_core_block_text_list, ,这显示了分配给其的子块的串联输出,因此,如果不添加小部件,它将是空的。现在,当布局准备好用于小部件配置时,请检查下一步。

  2. 创造 widget.xml 文件中的文件 ETC 主题目录(如果您不愿从主题中保留此配置,则需要将其从该主题复制到您的主题)。此widget.xml应包含Magento的其他信息,以了解哪些小部件支持您新创建的容器:

    <widgets>
        <[widget_id]>
            <supported_blocks>
                <left_column_top>
                    <block_name>left_top</block_name>
                </left_column_top>
             </supported_blocks>
        </[widget_id]>
    </widgets>
    

    此配置文件让Magento知道哪些块可用于检索管理面板中可能的容器。

播种您可以进入管理面板,然后选择您的 左列顶部 用于小部件布局更新的容器。

其他提示

您可以尝试使用

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('BLOCK_ID_HERE')->toHtml() ?>

将上述代码插入:

frontend/default/yourtheme/template/catalog/navigation/sidebar.phtml

在显示目录菜单的代码上方。

为了防止在各个网站上显示它,每个网站都会使用不同的主题。

许可以下: CC-BY-SA归因
scroll top