Magento render cms/block with widgets

You create a cms static block (cms/block) and dynamise it with widget, here an example:

 <div class="confirmation">
        <img src="{{skin url='images/image-order.jpg'}}" alt="" />
 </div>

You then render this block :

echo Mage::getModel('cms/block')
            ->setStoreId(Mage::app()->getStore()->getId())
            ->load(self::confirmationCmsBlockName)->render();

But the widget {{skin url=’images/image-order.jpg’}} is not executed and is display as {{skin url=’images/image-order.jpg’}}.

To execute the widget, you need to render as HTML a block and not a model

echo  Mage::app()->getLayout()->createBlock('cms/block')->setBlockId(self::confirmationCmsBlockName)->toHtml();

Leave a Reply