Last active
January 7, 2021 14:08
-
-
Save AndreaRivadossi/21ad5e467f469837fefacdeced4d674f to your computer and use it in GitHub Desktop.
Magento 2 - Add a CMS static block in a .phtml or .xml layout file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('my-custom-block')->toHtml(); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{block class="Magento\Cms\Block\Block" block_id="my-custom-block"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<block class="Magento\Cms\Block\Block" name="my-custom-block"> | |
<arguments> | |
<argument name="block_id" xsi:type="string">my-custom-block</argument> | |
</arguments> | |
</block> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo $this->getChildHtml('my-custom-block'); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment