In order to add static block in page (.phtml) template. Follow the steps below:
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 write the following code:
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>
In CMS Content just write the following line:
{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}
Now its all done!. Static block has been added
0 Comment(s)