We have three method for call static block in magento.
=> PHP
Adding static block inline with PHP is the quickest way to get block in your template.
Following code will help you for display static block from your phtml file
echo $this->getLayout()->createBlock('cms/block')->setBlockId($identifer)->toHtml();
Note : $identifer = your_block_id
=>XML
Adding a static block to a page template is a great way to control global elements of your site
We can embed this code in app > design > frontend > default > your_theme > layout.
Open the appropriate the file, lets say catalog.xml and put the following code in the block for our category view
Following code will help you for display static block from your xml file
<block type="cms/block" name="your_block_id" before="-">
<action method="setBlockId"><block_id>your_block_id</block_id></action>
</block>
Or we can call block in another block also in CMS Page
=> Shortcode
This technique is used when we need to pull in a static block while in Magento’s admin creating CMS pages or other static blocks.
Following code will help you for display static block from other static blocks OR CMS pages.
No comments:
Post a Comment