Pergunta

In default RWD theme, it uses the following code for showing company footer

<default>
    <reference name="footer">
        <block type="cms/block" name="cms_footer_links" before="footer_links">
            <!--
                The content of this block is taken from the database by its block_id.
                You can manage it in admin CMS -> Static Blocks
            -->
            <action method="setBlockId"><block_id>footer_links_company</block_id></action>
        </block>
        <block type="cms/block" name="cms_footer_links_sm" after="footer_links2">
            <!--
                The content of this block is taken from the database by its block_id.
                You can manage it in admin CMS -> Static Blocks
            -->
            <action method="setBlockId"><block_id>footer_links_sm</block_id></action>
        </block>
    </reference>
</default>

The problem is the block will not change according to different store view, so how can I change it to support multiple languages?

Foi útil?

Solução

You don't need to call the static block for different languages by code explicitely.

Suppose you want to show the company info in different languages using static blocks, you need to create different static blocks for the same info for different languages and keep the identifier for these static blocks same.

For example, for the English language:

  • Block Title: Footer Company Info English
  • Identifier: footer_links_company
  • Store View: English

Similarly, for the French language:

  • Block Title: Footer Company Info French
  • Identifier: footer_links_company
  • Store View: French

Now, you can call a single static block like:

<block type="cms/block" name="cms_footer_links" before="footer_links">
    <action method="setBlockId"><block_id>footer_links_company</block_id></action>
</block>

and that's it. Magento will automatically switch from one language to other when the store view is changed.

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