Magento: how to add a Static Block to a page

Static Block of Magento is a very useful tool for us to add some static content. Copy the line of code below where you want the static block to appear and change the ‘identifier’ to the identifier of the static block you created.

getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>

Fox example, you just add a static block named “header_content”, and named the identifier “header_content”, then you will add it at the top menu of every page of your website, so, do it like this:

1, look the header.phtml at app/design/frontend/default/your-template/template/page/html

2, add the code:
getLayout()->createBlock('cms/block')->setBlockId('header_content')->toHtml() ?>
to header.phtml.

3, upload the header.phtml to your server, that’s all.

Share |

Comments are closed.