Magento static CMS block in XML layout with two or more storeviews

backyardKiwi picture backyardKiwi · Jun 24, 2011 · Viewed 46k times · Source

I have two static CMS Blocks called "promo_en" and "promo_de" - translated for the two existing storeviews "en" and "de".

I'd like to add them to the sidebar of some modules using the layout.xml files of the modules.

The problem is that if I add them both using the following syntax - they both show disregarding the storeview I'm currently in (I would expect some automatic filtering):

<block type="cms/block" name="Promo_de">
    <action method="setBlockId"><block_id>promo_de</block_id></action>
</block> 
<block type="cms/block" name="Promo_en">
    <action method="setBlockId"><block_id>promo_en</block_id></action>
</block> 

If I rename them both to "promo" and use the following syntax - it works fine until I activate Magento's cache - then the output of the CMS block freezes on whatever storeview is cached first:

<block type="cms/block" name="Promo">
    <action method="setBlockId"><block_id>promo</block_id></action>
</block> 

And ideas or workarounds on the matter are highly appreciated.

Answer

clockworkgeek picture clockworkgeek · Jun 25, 2011

As a rough workaround you can use layout handles specific to each store. For example;

<STORE_de>
    <reference name="left">
        <block type="cms/block" name="Promo_de">
            <action method="setBlockId"><block_id>promo_de</block_id></action>
        </block> 
    </reference>
</STORE_de>
<STORE_en>
    <reference name="left">
        <block type="cms/block" name="Promo_en">
            <action method="setBlockId"><block_id>promo_en</block_id></action>
        </block> 
    </reference>
</STORE_en>