How to call static block in magento

0
42
Static block

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

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

How to creating a link to another page within your site

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

How to call staic block any XML file

1
2
3
4
5
<reference name="left">
    <block type="cms/block" name="sample_block" before="-">
        <action method="setBlockId"><block_id>sample_block</block_id></action>
    </block>   
</reference>

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

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

How to call static block in CMS->Pages

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

 

Ref: justwebdevelopment