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

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

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.

This post is also available in: enEnglish

Recent Posts

Leave a Comment

 

Contact Us

Send us a quick message, we will get back to you as soon as we see it.

Not readable? Change text. captcha txt

Start typing and press Enter to search

can social media profiles replace good old websites for small local businesses