Magento static Blocks – How to Access Magento Static Blocks

Thursday, 4. August 2011

If you ever wanted to add static block’s content to some of your Magento files or CMS pages, these lines may be what you are looking for:

Layout blocks at the right column of the page:

Add static block content to he right side column

<block type=”core/text_list” name=”right” as=”right”>
<block type="cms/block" name="">
       <action method="setBlockId"><block_id>your-block-id</block_id></action>

Add static block a template file (.phtml)

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>

Add static block in a CMS Page

{{block type=”cms/block” block_id=”block-id”}}

Add template file (that may contain static block contents) in a CMS Page

{{block type=’core/template’ template=’cms/customfile.phtml’}}

Access Static Blocks in Block classes

$block = Mage::getModel('cms/block')->load('block-identifier');
echo $block->getContent();
echo $block->getTitle();

Leave a Reply

You must be logged in to post a comment.