Call static block in Magento

Static block is use to allow store Admin to update content or any block without changing code. Admin can update content from admin-panel easily. We can call static block in different location in Magento. I.e. in CMS page,
any of phtml file, any block etc.

Below are syntax to call static block in different location.

1) Magento: call a static block in a phtml file.

To call a static block in a phtml file you just need to replace static block id in below code. Put this code where you want to call.

echo $this->getLayout()->createBlock('cms/block')->setBlockId('static_block_id')->toHtml();

2) Magento: call a static block in CMS page.

use below code to call static block in CMS page.

{{block type="cms/block" block_id="static_block_id"}}

3) Magento: call static block in xml.

syntex to call static block using xml file

<block type="cms/block" name="home-page-block">
<action method="setBlockId"><block_id>home-page-block</block_id></action>
</block>

Tags: Magento1,

Related Posts

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *