Magento Template Editing : How to add a new static block to a phtml template

This is a good practice to use if you have something added to your magento templates that require frequent updates, like a message on the header part of the website.

  1. Log into your Magento Admin panel and navigate to CMS -> Static Blocks 
  2. Add new static block and remember to specify your Block Title and Block Identifier.
  3. Using your FTP client or any FileManager, navigate to app\design\frontend\default\themeXXX\template\page\html folder.
  4. Open the required phtml file using any text editor. E.g. header.ptml should you want to add this static block to header.
  5. Add below PHP code to the file.
  6. <?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘custom_block_id’)->toHtml() ?>
  7. save file, upload and refresh the website after clearing cache.

Tags :

Written by: Rocken
Written by: Rocken

Natoque viverra porttitor volutpat penatibus himenaeos. Vehicula commodo si hendrerit.

Latest Post

Categories

The designs you will crave for

Lorem ipsum dolor sit amet consectetur.