Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dawqss/2a371f4820d979bfe7192477acc2d13b to your computer and use it in GitHub Desktop.
Save Dawqss/2a371f4820d979bfe7192477acc2d13b to your computer and use it in GitHub Desktop.
Magento 2 - Include Static Blocks (template/cms/layout)

In .phtml tempalte 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"}}

In layout .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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment