In between Magento 1.x and 2.x, rendering the Static block is quiet different. You can call either in .phtml template, CMS page or layout file in the following way.
In phtml file:
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block-identifier')->toHtml();?>
In any CMS block:
{{block class="Magento\Cms\Block\Block" block_id="block-identifier"}}
In layout 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>
In phtml file:
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block-identifier')->toHtml();?>
In any CMS block:
{{block class="Magento\Cms\Block\Block" block_id="block-identifier"}}
In layout 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>
No comments:
Post a Comment