Categories
Programming

Magento – Check if CMS Static Block is Enabled / Active

Static blocks in Magento are really useful. They offer an easy way to insert content into various parts of the template. You are only limited by your imagination. You can check if the static blocks are enabled, before printing them to screen.
[php]
<?php

if(Mage::getModel(‘cms/block’)->load(‘static-block-identifier’)->getIsActive()) :

echo Mage::app()->getLayout()->createBlock(‘cms/block’)->setBlockId(‘static-block-identifier’)->toHtml();

endif;

?>
[/php]

By Kathir Vel

An agile ebusiness & marketing consultant based in Edinburgh, Scotland, UK. ICT specialist with a MBA in marketing and strategy. Seasoned project manager with strong roots in advertising campaigns and film making. Loves photography and travelling.

Leave a Reply

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