Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 305 Vote(s) - 3.57 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Magento static CMS block in XML layout with two or more storeviews

#1
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.
Reply

#2
As a rough workaround you can use [layout handles](

[To see links please register here]

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

#3
I ended up writing my own Mini-Module to quickfix the problem, switching the translations in code based on the current store code:

if( Mage::app()->getStore()->getCode() == 'de' )
{
echo $this->getLayout()->createBlock('cms/block')->setBlockId('promo_de')->toHtml();
}
else if( Mage::app()->getStore()->getCode() == 'en' )
{
echo $this->getLayout()->createBlock('cms/block')->setBlockId('promo_en')->toHtml();
}

I know it's ugly but time really was an issue here and I'll have to clean this up in the future...
Reply

#4
Why not create the static blocks with same identifier, and then only enable them in corresponding store view?

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

Then create 2 static blocks with identifier promo and only enable them in storeview where they belong?
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through