How to display different Static Blocks based on Category in Magento
The code below can be used in the template/page .phtml files and has been used in the 2column-left.phtml file:
<?php $category = Mage::getModel('catalog/layer')->getCurrentCategory();?> <?php if($category->getId()==24): ?> <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-for-cat24')->toHtml() ?> <?php elseif($category->getId()==23): ?> <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-for-cat23')->toHtml() ?> <?php else: ?> <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-for-everything-else')->toHtml() ?> <?php endif; ?>