Static Blocks Magento

Hello all,

I am writing here the code for getting the status of the CMS static block of the required block id.


<?php 
        $blockId = "category_block"; //block id to be assigned here
	$block = Mage::getModel('cms/block')
	    ->setStoreId(Mage::app()->getStore()->getId())
	    ->load($blockId);
	echo $title = $block->getTitle(); // get block title
	$isActive = $block->getIsActive(); // get block status	
	if($isActive==1):
	    $block_html = Mage::getLayout()->createBlock('cms/block')->setBlockId($blockId)->toHtml(); //get block content if block is active				
        endif;
?>

Hope this is helpful

One thought on “Static Blocks Magento

Leave a Reply

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

Scroll to top