There are Three Ways to access static block in Magento.
- Inside a template file using PHP
- Inside a content field of a CMS Page in the Magento admin
- Inside the Layout Update XML field of a CMS page in the Magento admin
1- Accessing a Magento Static Block From a PHP Template File:
First Way:
<?php
echo $this->getLayout()->createBlock('cms/block')->setBlockId('test_block1')->toHtml();
?>
Second Way:
<?php
$staticBlock1 = Mage::getModel('cms/block')->load('test_block1');
if($staticBlock1->getIsActive() == 1) {
echo $staticBlock1->getTitle() . '<br />';
echo $staticBlock1->getContent() . '<br />';
}
?>
2- Accessing a Magento Static Block From A CMS Page:
{{block type="cms/block" block_id="block-id-in-magento"}}
3- Adding a Static Block to the CMS Page Layout Update XML FIeld:
<reference name="content">
<block type="cms/block" name="block.name">
<action method="setBlockId"><block_id>block-id-in-magento</block_id></action>
</block>
</reference>
1 Comment
Sushant Vishwas · March 20, 2015 at 2:46 pm
Reblogged this on <a href=”https://sushantvishwas1990.wordpress.com/2015/03/20/magento-get-static-block/” rel=”nofollow ugc”>sushant vishwas</a>.