How to call a static block in Magento

call-static-block

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:

<default>
    <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>
            </block>
        </reference>
    </cms_page>
</default>

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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>