Magento: get a static block as html in a phtml file

iamjonesy picture iamjonesy · Jan 12, 2011 · Viewed 173.1k times · Source

I have a static block called newest_product (with content) and I would like to display it on a .phtml file as html.

I've tried this code:

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

But this nothing is being displayed.

Am I using the wrong code?

Answer

Suman-PHP4U picture Suman-PHP4U · Nov 27, 2012

If you have created CMS block named 'block_identifier' from admin panel. Then following will be code to call them in .phtml

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