Static block is the easiest way to display your HTML content into your Magento eCommerce template. Suppose you have some static content or banner in your header that will change in every week or once in a month and wish to appear on the home page. Well, you can do that with static block functionality. Once you have created static block you can update with replacing content, image or anything you want to display.

 Step 1:

Creating a static block.

  • In Magento admin panel go to CMS > Static Blocks.
  • Add New Block.
  • Fill up required general information.
  • Now Save Block.

Step 2:

Adding a block to your .phtml file.

In my case and for the demonstration of this example, I am going to display into the home page and for that, I am adding below code in content_heading.phtml which is located at “frontend\base\default\template\cms\content_heading.phtml”.

Copy the below code and paste in content_heading.phtml file and add setBlockId with your Identifier.

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('lorem-ipsum')->toHtml() ?>

Leave a Reply

%d bloggers like this: