Adding static blocks to specific CMS pages with Magento layouts

First, we will create a static block that we want to add to a specific CMS page which we’ll name static-block-element and apply some simple styles to it.

Static Block

This is static block content element

Next, we will create a new CMS page that will contain the created static block which will be added through Layout Update XML on Designs tab, along with a header and one paragraph. For this example, we’ll use 1 column layout for all CMS pages.

<reference name=”root”>
<block type=”cms/block” name=”staticelement”>
<action method=”setBlockId”><block_id>static-block-element</block_id></action>

And finally, we have to update our template files and add a line of code which calls our element. Since we used 1 column layout for all CMS pages and we will modify 1column.phtml template file. If you want to add the elements to CMS pages that use some other template (like 2columns-left), you need to modify those files.

<div class=”page-content”>
<?php echo $this->getChildHtml(‘header’) ?>
<?php echo $this->getChildHtml(‘staticelement’) ?>