Adding a Static Block to your .phtml files in Magento

28 Jul 2010
Adding a Static Block to your .phtml files in Magento

There are various ways to call your static blocks to your Magento frontend out there but if you are working in the .phtml and .xml files then you’d have some reading to do just to get it to work. Let’s go step by step:


1. Create 1 CMS Static Block at CMS/Static Block /Add new Block


2. Call a Static Block to your .xml files in Magento: Go to your .xml file in your Magento template’s LAYOUT folder. Just paste this code:
<block type="cms/block" name="cms_test_block" before="-">
    <action method="setBlockId"><block_id>cms_test_block</block_id></action>
</block>

You can call it by it’s name in file .phtml
<?php echo $this->getChildHtml('cms_test_block') ?>


3. Call a Static Block to your .phtml files in Magento: Go to your .phtml file, where you would like that static block to appear, then paste this code:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(cms_test_block)->toHtml() ?>

If you have any further problem please email us at: [email protected]

Related Posts

Magento - Layered navigation on product pages

Magento - Layered navigation on product pages

20 Jul 2010
To attract more potential customers to your online store, you must create an ease for them when browsing products they need. In Magento, Layered Navigation is a useful feature that allows customers to find item according to two default properties: Price and Categories.
Upgrade magento theme from 1.4.0.1 to 1.4.1.0

Upgrade magento theme from 1.4.0.1 to 1.4.1.0

16 Jul 2010
Finally, Magento version 1.4.1.0 has been released, and much improved since 1.4.0.1. Here is the tip for fixing common theme issue while upgrading.