Home » Magento

Magento: How to call static block from template file?

4 December 2009 5,131 views Popularity: 11% Share/Bookmark

email

You can easily call any static block from template (phtml) file. At first, you have to create a static block.

Let us suppose, you created a static block with the identifier cool_items.

Now, you can call the static block from any phtml file with the help of following code:


<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('cool_items')->toHTML();?>

Related posts:

  1. Magento: How to call block directly from phtml file without defining in layout?
  2. Magento: Create CMS Page & Static Block programmatically
  3. Magento: Block Controller Model Helper Override
  4. Magento: Fatal error: Call to a member function getTable() on a non-object
  5. Magento: Fatal error: Call to a member function setSaveParametersInSession() on a non-object
  6. Magento: How to upload file?
  7. jQuery: Grey out background and preview image as popup
  8. Installing the Smarty Template Engine
  9. An Introduction to Smarty Template Engine
  10. Magento: Adding attribute from MySql setup file
  • Wouter

    Thank you so much for this! I could not get it to work but with this code it does :-)

  • Puja Sinha

    Thank You.
    This code really helped

  • http://modraideja.com modra ideja

    tnx, nice and simple :)

  • http://www.justwebdevelopment.com/ Merk

    You are so awsoeme for helping me solve this mystery.