Static blocks are blocks that help display different types of content for advertising purposes on one or more sites.

These blocks can display variety of content including:

  • Banner
  • Sidebars
  • Photos
  • Size charts
  • Return policies

The whole purpose of creating these static blocks is to streamline how much time it takes to update your site. You don’t have to dive into the hundreds of lines of code -time to update the changes!

Now let’s move in step by step procedure and make it happen, yeah?

1. Adding Static Block in XML File

Adding Static Block
2. How to Call Static Block in Magento 2 CMS Page

For carrying out this stage there is sub procedure one has to do and it goes like:

I. Go to the Magento store’s Admin Panel, from the left corner of the page, navigate to the Content tab and then click on the Pages option.

Calling Static Block
II. Click the Edit on the [Your Page].

Click Edit on Page
III. Go to the Content section and add block code:

{{block class=”Magento\Cms\Block\Block” block_id=”[Identifier]”}}

Add Block Code
IV. Finally, Click Save.

3. How to Call Phtml File in CMS Page in Magento

Step1. Go to the Admin Panel of the Magento store, navigate to the Content tab from the left corner of the page and then click on the Pages option.

Step2. Click the Edit on the [Your Page].

Step3. Go to the Content section and add block code:

{{block class=”[BlockClassFullName]” template=”[VendorName]_[ModuleName]::[YourTemplateFileLocation].phtml”}}

For example:

{{block class=”Magento\Bannerslider\Block\Slideshow” template=”Magento_Bannerslider::bannerslider.phtml”}}

Step 4. Click Save.

Previous Next