How to Add a Static Block to Your Magento Theme

When creating your magento theme, you often will want to insert cms static blocks rather than keeping all of the content in the theme. The store owner is going to want to change the content now and again and if you do as much as possible with static blocks, they can be edited in the Magento Admin.

Place in the appropriate layout file and scope. If this was, for example, a static block in the footer, you would need to add it in app/design/frontend/[interface_name]/[theme_name]/layout/page.xml inside the scope of the “footer” block.

<block type="cms/block" name="reference_to_static_block">
    <action method="setBlockId"><block_id>name-of-static-block</block_id></action>
</block>

The name-of-static-block has to be the static block identifier in Magento Admin -> CMS -> Static Blocks

Then in your template, continuing with the example of it being in the footer, we then get static block content using this sweet and simple line in app/design/frontend/[interface_name]/[theme_name]/template/page/html/footer.phtml:

<?php echo $this->getChildHtml('reference_to_static_block') ?>

Posted by Tom.

About Tom: Magento Loving Managing Director at Meanbee. Main tasks include coding magento themes, drinking tea and reminding Nick what he should be doing.

View the original version of this post.

Leave a Reply

  • You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tweets from @meanbee

Contact Meanbee

Send us your message