Pergunta

I have a widget setup on all category pages via backend -> CMS - > Widgets

Now when I use this method I select a block for category pages and the block shows up nicely. It is at the bottom of all other information in the left column.

But how do I move the block up to top? (above layered etc) ...

The alternative is to use local.xml, that I do not prefer + it also then shows up on ALL my websites that use the same theme.

Foi útil?

Solução

The problem is that Magento doesn't have widget container on top of left column. You can create such a container in two steps:

  1. Create you widget block container in local.xml file:

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

    In the following example catalog_category_default and catalog_category_layered are the handles for category pages and custom_top_container handle is included into these pages by update layout instruction. The new left_top block is a type of Mage_Core_Block_Text_List, that shows concatenated output of child blocks assigned to it, so it will be empty if no widget is added to it. Now when layout is ready to the widget configuration, check the next step.

  2. Create widget.xml file in etc directory of your theme (if you wan't preserve this configuration from theme you are extending, then you need to copy it from that theme into yours). This widget.xml should contain additional information for Magento to know which widgets supports your newly created container:

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

    This configuration file lets Magento know which blocks can be used for retrieving of possible container in the admin panel.

Sow you can go in the admin panel and choose your Left Column Top container for widget layout update.

Outras dicas

You could try calling in that block using

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

Insert the above code into:

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

above the code that displays the catalog menu.

To keep it from displaying in across websites use different themes per website.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top