There are Three Ways to add 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
Accessing a Magento Static Block From a PHP Template File
<?php // Retrieve the layout object $layout = Mage::getSingleton('core/layout'); // Generate a CMS block object $block = $layout->createBlock('cms/block'); // Set the block ID of the static block $block->setBlockId('block-id-in-magento'); // Write the static block content to screen echo $block->toHtml();
Accessing a Magento Static Block From A CMS Page
{{block type="cms/block" block_id="block-id-in-magento"}}
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>
NOTE : Replace “block-id-in-magento” With your Static Block Name.
You must be logged in to post a comment.