search
top

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 Response to “Static Blocks Magento”

  1. monojones says:

    Thanks very interesting!

Leave a Reply

top