I am trying to call a static block in the footer block but it does not work.
I created a theme and then created a default xml:
\app\design\frontend\MyTheme\Theme-frontend-default\Magento_Theme\layout\default.xml
i then removed the default footer links:
<referenceBlock name="footer_links" remove="true"/>
i then added the code to the block:
<referenceContainer name="footer">
<block class="Magento\Cms\Block\Block" name="footer_navigation">
<arguments>
<argument name="footerNavigation" xsi:type="string">footer_navigation</argument>
</arguments>
</block>
</referenceContainer>
I had earlier created the block programmatically using an InstallData.php :
$cmsBlock = $this->blockInterfaceFactory->create();
$cmsBlock->setIdentifier('footer_navigation')
->setTitle(self::Footer_Navigation)
->setContent('{{block class="Topclick\CmsPages\Block\Cmspages" template="Topclick_CmsPages::blockTemplates\footerNavigation.phtml"}}')
->setData('stores', [0]);
$this->blockRepository->save($cmsBlock);
so. i am unclear why its not working. i did however test the block and it does indeed render on normal pages using this:
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('footer_navigation')
->toHtml();
Why my xml doesn't work ?
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer_navigation')->toHtml(); ?>
doesn't work after clearing cache ?