Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gil--/baf32e9776a87a689b15aca1e2d800d8 to your computer and use it in GitHub Desktop.
Save gil--/baf32e9776a87a689b15aca1e2d800d8 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