Frontend – Adding a Static Block Multilingual Footer

The footer in a Magento site can be specified in a few ways. The most popular way that I have determined is from a combination of static blocks, and layout files.

Let’s consider the typical default layout in this here example. If you cast your eyes to the code below.

/app/design/frontend/base/default/layout/page.xml:

    <default translate="label" module="page">
        <label>All Pages</label>
        <block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
            .
            .
            .
            <block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
                <block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
                    <label>Page Footer</label>
                    <action method="setElementClass"><value>bottom-container</value></action>
                </block>
                <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
                <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
            </block>
            .
            .
            .
        </block>

        <block type="core/profiler" output="toHtml" name="core_profiler"/>
    </default>

A delightful and well meaning piece of xml, I am sure that you will agree. For more information regarding the intricacies of layout files, then you may want to read a more detailed definition at the layouts page.

However, we want to add something specific, that we need to make in the administrator area so that the client can modify that content. To achieve this we create some static blocks. Administrator -> CMS -> Static Blocks. Then create the block that needs to be created. In the case of requiring multiple languages of the same block, create multiple blocks but give them all the same identifier value, but make sure to associate each static block with the Store View dropdown specified in the static block definition area.

Return to the page.xml file defined above and modify code similar to the following:

             <block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
                <block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
                <block type="cms/block" name="cms.footer_links" as="<static_block_ identifier>">
                    <action method="setBlockId"><block_id><static_block_ identifier></block_id></action>
                </block>
                    <label>Page Footer</label>
                    <action method="setElementClass"><value>bottom-container</value></action>
                </block>
                <block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
                <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
            </block>

Please replace shown in the code to the identifier that was specified in the block/s created in the Administrator -> CMS -> Static Blocks area.

Note that you do not need to worry about the appending anything regarding language changes of the site as this will all be handled

I attempted to add a new static block in the administrator area of the Magento site, giving it the reference name of “footer”. However nothing would display. On further investigation it was seen that the local.xml file had deactivated this from functioning with the following code:

/app/design/frontend/default//layout/local.xml

        <!-- 
               	Default Footer 
        -->
        <reference name="footer">
            <action method="unsetChild">
                <alias>cms_footer_links</alias>
            </action>
            <block type="cms/block" name="footer_block">
                <action method="setBlockId">
                    <block_id>footer_block</block_id>
                </action>
            </block>
        </reference>

This was an early trial to see what would happen, and not particularly relevant, but I thought to add it as a mater of completeness. 🙂

Resources:
http://magento.stackexchange.com/questions/617/how-to-create-multilingual-static-block

Leave a Reply

Your email address will not be published. Required fields are marked *