How to call a static block in Magento

There are two ways of calling a static block in magento:

First through Layout XML files, second through phtml file.

XML Method:

In the layout (app/design/frontend/default/your_theme/layout/local.xml),add the follwing code:

    <cms_page> <!-- need to be redefined for your needs -->
        <reference name="content">
            <block type="cms/block" name="cms_news" as="cms_news">
                <action method="setBlockId"><block_id>news</block_id></action>

In the phtml file call:

<?php echo $this->getChildHtml('news'); ?>


PHTML File Method:

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

Leave a Reply

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