Categories
magento 2 Magento Developer

Display CMS Static Block Magento2

Magento Developers are usually used the following techniques to call a static block.

Display CMS Static Block In Phtml File:

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

 

Display CMS Static Block In CMS Content:

{{block class=”Magento\\Cms\\Block\\Block” block_id=”block_identifier”}}

Display CMS Static Block In XML:

<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>

 

Leave a Reply

Your email address will not be published. Required fields are marked *