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

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

July 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento static CMS block in XML layout with two or more storeviews

Managing Magento Static CMS Blocks Across Multiple Storeviews

As an experienced developer working with Magento e-commerce platforms, I often encounter challenges when managing static CMS blocks across multiple storeviews. In this post, we’ll explore how to properly configure your layout XML files to display the correct CMS block based on the active storeview.

The Problem: Displaying Block Content in Multiple Storeviews

Let’s start by understanding the issue you’re facing. You have two static CMS blocks—“promo_en” and “promo_de”—created for English (en) and German (de) storeviews, respectively. You want to add them to the sidebar of some modules using the layout XML files.

However, when you include both blocks in your layout file using Magento’s block configuration syntax, they both show up regardless of the active storeview. This is unexpected because you’d assume that Magento would automatically filter and display the CMS block corresponding to the current language setting.

A Closer Look at Your XML Configuration

Let’s examine the two approaches you’ve tried:

Approach 1: Separate Blocks for Each Storeview

In your first attempt, you named each block using the country code followed by “Promo” (e.g., “Promo_de”, “Promo_en”).

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

This approach does work, but it’s not efficient. Having separate blocks for each storeview results in unnecessary code duplication and increased memory usage.

Approach 2: Single Block with Cache Dependency

In your second attempt, you renamed both blocks to “Promo” and added a cache dependency on the page layout.

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

This solution works until you enable Magento’s caching system. Once the cache is activated, the output of the CMS block gets frozen on whatever storeview was rendered first and remains static even when you switch between languages.

The Solution: Using Magento’s Layout Update XML

To resolve this issue efficiently, we’ll use Magento’s layout update XML feature to conditionally display the appropriate CMS block based on the active storeview.

  1. Create a new layout update file (e.g., catalog_category_view.xml) in your module’s layout folder.

  2. Define your block with the correct ID and add a conditional rule for each storeview.

<layout version="1.0">
    <update handle="catalog_category_view">
        <reference name="sidebar.right">
            <block type="cms/block" before="-" template="promo.phtml">
                <action method="setBlockId"><block_id>promo_en</block_id></action>
                <condition module="Mage_Core_Model_Store">
                    <![CDATA[$this->getRequest()->getParam('store') == 'en']]>
                </condition>
            </block>
        </reference>
    </update>

    <update handle="catalog_category_view">
        <reference name="sidebar.right">
            <block type="cms/block" before="-" template="promo.phtml">
                <action method="setBlockId"><block_id>promo_de</block_id></action>
                <condition module="Mage_Core_Model_Store">
                    <![CDATA[$this->getRequest()->getParam('store') == 'de']]>
                </condition>
            </block>
        </reference>
    </update>
</layout>

In this example, we’ve created two layout updates for the “catalog_category_view” handle. Each update defines your CMS block with the correct ID and adds a condition that checks whether the current store is ‘en’ or ‘de’. The <condition> node ensures that only the appropriate block is rendered based on the active storeview.

Why This Approach Works

Using layout updates allows you to maintain a single, efficient configuration while still displaying the correct CMS content for each storeview. By applying conditions within the layout XML, Magento can dynamically render the appropriate block without requiring separate blocks or caching issues.

Additionally, this approach promotes better code organization and easier maintenance of your e-commerce platform.

Conclusion: Efficient Management of Magento CMS Blocks Across Storeviews

In summary, to properly manage static CMS blocks across multiple storeviews in Magento:

  1. Avoid creating separate blocks for each language.
  2. Utilize layout updates XML files with conditional rules based on the active storeview.
  3. Apply this approach consistently throughout your modules and layouts.

By following these best practices, you can ensure that your e-commerce site displays the correct CMS content for each language without compromising performance or introducing caching-related issues.

For more information on Magento development best practices and advanced layout configurations, be sure to explore our comprehensive guide at LaravelCompany.

Extensions Themes Configuration Pricing

Our network