Getting Magento static Block in template page(phtml file)

One of the great feature of Magento is the static block which makes it’s CMS system really flexible. Here is the way how to create static block from admin and getting it in Magento Template page

  1. Login in Magento admin and go to CMS->Static Block
  2. Then click on Add New Block
  3. Then give the title of the Block and Identifier of the block (it is my_static_block in this example. This should be unique and please don’t include special character. If there is multi domain or multi store select and then Enable yes and then write the content that you want in your static block

Now this static Block can get from our template file(phtml file) in our magento design directory(for example app/design/default/default/template/page/html/header.phtml) with following code

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

please don’t forget my_static_block our static block Identifier.

Leave a Reply

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