Today I had a task to insert static blocks into footer area of Magento web page. Since there are some troubles with WYSIWYG editor and html code I opted to make it more secure for future editing so I wanted to give the static blocks their template. I’m guessing that you know how to add static block into footer area. (Hint! Add it in local.xml).
In order for static blocks to be able to have template you have to call them as a type cms/widget_block instead of cms/block. This will allow your blocks to have template because by default static blocks don’t have a template. Here’s how the footer part of my local.xml looked like:
<reference name="footer"> <block type="cms/widget_block" name="cms_footer_socials" template="cms/footer_area.phtml"> <action method="setBlockId"> <blockId>identifier</blockId> </action> </block> </reference>
And in my theme I added cms/footer_area.phtml that with this code. Edit it to suit your needs:
<?php $id = $this->getBlockId(); $block = Mage::getModel('cms/block')->load($id); ?> <div class="block"> <div class="title"><?php echo $block->getTitle() ?></div> <div class="content"><?php echo $block->getContent() ?></div> </div>
And now my static blocks in footer area have their template 🙂 .