Magento: How To Add Static Blocks

November 12th, 2011 | Posted by hhanifl in Magento | SEO & Internet Marketing

Add a Static Block from a CMS Page :

First create the the static block. Lets say, the identifier you used is “my_block” Now goto your CMS page and paste this in the content box,

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

Then click on Design > Page Layout on the same CMS page edit screen. And paste this,

<reference name="content"> <block type="cms/block" name="my_block"> <action method="setBlockId"><block_id>my_block</block_id></action> </block> </reference>

Thats all. Clear cache and you should be able to see your static block on frontend.

Add a Static Block from the PHTML file :

If you want to call a static blockĀ  from a magento template file, the .phtml files, then here is how to do that. Just edit the .phtml file and place this code with your static block identifier,

<?php echo$this->getLayout()->createBlock('cms/block')->setBlockId('my_block')->toHtml() ?>

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

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

*

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