Show Static Block in PHTML Template

Displaying a Magento admin static block in your .phtml template files is quick and easy.

Simply create a new static block, for example the Block Title could be Footer Links and the Identifier static_footer_links. Add in some filler text or if you prefer some Ryker Ipsum. Now, save the Static Block.

Next, in your .phtml template files paste the following code:

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

Notice that the block_identifier is only a placeholder for our example. Replace the block_identifier with your new Static Block Identifier. For this example: static_footer_links. Your final code will look like this.

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

Finally, save the file and refresh the page you’ll see your Static Block content show up.

Remember you can also wrap this code snippet with a class or id for styling purposes like so:

<div id="footer-links-container">
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('static_footer_links')->toHtml(); ?>

Or you can place the wrapping div with class or id in your static block surrounding your code.