Magento2- Display Static Block in Phtml file & CMS page


In XML File:

<referenceContainer name="content">
<block class="Magento\Cms\Block\Block" name="block_identifier">
<arguments>
<argument name="block_id" xsi:type="string">block_identifier</argument>
</arguments>
</block>
</referenceContainer>

In Phtml File:

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>

in CMS Content:

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}
Advertisements

5 thoughts on “Magento2- Display Static Block in Phtml file & CMS page

  1. Hi, please can you tell me, how can i call my module block(not cms static block) in phtml(template folder) file in Magento 2?
    Thanks

  2. Hi, please can you tell me, how can i call my module block(not cms static block) in phtml(template folder) file in Magento 2?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s