Tuesday, February 14, 2012

Most Frequently Used Functions in Magento

1)Magento: How to call static block from template file?
We can Easily call a static block directly from template.
Let us suppose, you created a static block with the identifier aforankur_link.
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(‘aforankur_link’)->toHTML();?>

2)Magento: How to call block directly from phtml file without defining in layout?
<?php echo $this->getLayout()->createBlock(‘newmodule/newblock’)->setTemplate(‘newmodule/newblock.phtml’)->toHtml(); ?>

3)Magento: Add Static Block to CMS Page
{{block type=”cms/block” block_id=”home-page-promo”}}

4)Magento :How to call a phtml file in magento cms page
{{block type=”core/template” name=”a-name” template=”cms/home.phtml”}}


5) Magento Store – Get Base URL in Static Block
Try adding this to your static block:
<a href=”{{store url=”"}}”>Link to Base URL</a>

6) Mageto  : Skin URL
<a href=”#”><img src=”{{skin url=’images/home/dog-playing.jpg’}}” alt=”"/></a>

7) Magento: get Url
<a href=”<?php echo $this->getUrl(‘about-us’)?>”>

No comments:

Post a Comment