Magento 2 : How to get static block as html content on frontpage?
-
25-02-2021 - |
質問
As we know that we're able to render html content up in front as using below code
echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('identifier')->toHtml();
but as I require to display as html content.
For eg: <div>This is static Block </div>
Like this up in front.
解決
You may try this
$blockHtml = $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('identifier')->toHtml();
echo $block->escapeHtml($blockHtml);
所属していません magento.stackexchange