How to call static block in magento

Home / Magento / How to call static block in magento

What is static block in magento?

Static blocks can be used throughout your theme wherever you want to make small updates to a section of a page. Typical uses would be for promotional banners/callouts in sidebars or for some custom text in the middle of your home page.
Static blocks can also be inserted into CMS pages or included in category pages.

Creating s static block

=> Login in into your magento admin panel.
=> Navigate to CMS->Static blocks
=> Click Add new block
=> Give your block title (Title: A descriptive name to identify this block)
=> Give your block identifier (Identifier: The identifer will allow you to call this block from your template files or using the Magento markup tags. Typically this would be programmer friendly name with no spaces or punctuation ie “my_block_identifier” rather than “My block’s identifer!”)
=> Set status enabled (Status: Here you can enable or disable a block.)
=> Entere your block content field (Content: As well as standard HTML you can also include special Magento markup tags in the block content. You can find information about these tags on the markup tags wiki page.)
=> Click Save Block or Save and Continue Edit to save your settings.

How to call image in static block

{{skin url='images/media/about_us_img.jpg'}}

How to creating a link to another page within your site

{{store direct_url='mypage.html'}}

How to call staic block any XML file

<reference name="left">
    <block type="cms/block" name="sample_block" before="-">
        <action method="setBlockId"><block_id>sample_block</block_id></action>

How to call staick block in your template or .phtml files

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

How to call static block in CMS->Pages

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

Related Posts

Leave a Reply

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