Home    Articles


How to add a static block in magento phtml file


First you need to set a new static block.
If you don’t want to use layouts to add it you can use php code to do that.

Go to your theme and find the file that you need modified and add the code bellow:

 echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml() 

Bellow you can see how to add static block into your layouts. This example is for left side.

<reference name="left">
   <block type="cms/block" name="you_reference_name" before="catalog.leftnav">
       	<action method="setBlockId"><block_id>you_reference_name</block_id></action>

That’s all. Enjoy.