Magento – Add static block in specific CMS page

cmsmagento-enterprisestatic-block

How can I add static block in specific CMS page?

Can I do it through Layout Update XML?

enter image description here

Best Answer

To add static blocks through Layout Update XML in CMS Pages use something like this code

<reference name="right">
    <block type="cms/block" name="your.1st.block.name" before="-">
        <action method="setBlockId">
            <block_id>your_1st_block_id</block_id>
        </action>
    </block>
    <block type="cms/block" name="your.2nd.block.name" after="-">
        <action method="setBlockId">
            <block_id>your_2nd_block_id</block_id>
        </action>
    </block>
</reference>

This example code will add two static blocks to the right sidebar, one at the top and one at the bottom. Of course, you will have to set your page layout to 2 columns with right sidebar in the example. If you have a 1 column layout then you could use "content" as a <reference>.

But there is another option, which may be easier for you, especially if you use the 1 colomn layout. You could also insert static blocks directly into the content area of your CMS Page with this code

{{block type="cms/block" block_id="your_block_id"}}