Magento: Inserting Static Block in Magento Templates


/ Published in: XML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* There are three ways to insert static blocks into magento templates */
  2.  
  3. /* 1.Inserting into example-template.phtml */
  4.  
  5. <?php
  6. echo $this->getLayout()->createBlock('cms/block')->setBlockId('MyCustomCMSPage')->toHtml() ;
  7. ?>
  8.  
  9.  
  10. /* 2. Inserting into CMS */
  11.  
  12. {{block type="cms/block" block_id="MyCustomCMSPage" template="cms/example-template.phtml"}}
  13.  
  14. /* 3. Inserting into layout.xml */
  15.  
  16. <layout>
  17. <example>
  18. <reference name="content">
  19. <block type="cms/block" name="cms_store_check">
  20. <action method="setBlockId"><block_id>MyCustomCMSPage</block_id></action>
  21. </block>
  22. </reference>
  23. </example>
  24. </layout>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.