Last active
November 22, 2017 06:27
-
-
Save devudit/c1eb0b7a22c8c33ae4da262e2ef4d797 to your computer and use it in GitHub Desktop.
Call static block in page
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 | |
// If you want to call static block in page | |
// Try below code : | |
{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}} | |
?> | |
<?php | |
//If you want to call in phtml file : | |
//Try below code : | |
echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml(); | |
?> | |
<?php | |
Your xml file code should be : | |
<referenceContainer name="sidebar.additional"> | |
<block class="Magento\Cms\Block\Block" name="yourblockid"> | |
<arguments> | |
<argument name="block_id" xsi:type="string">yourblockid</argument> | |
</arguments> | |
</block> | |
</referenceContainer> | |
//At Last if you want to call phtml with your block in cms page : | |
//Try below code : | |
{{block class="Magento\Modulename\Block\Blockname" template="Magento_Modulename::templatefilename.phtml"}} | |
// Refrence:- https://chetansanghani.wordpress.com/2015/11/20/magento2-display-static-block-in-phtml-file-cms-page/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment