How to call Static content block
-
14-04-2021 - |
Domanda
I want to create static block in Magento 2.3.5 and call that block in footer content. please anyone can have idea then please share with me.
Thank you in Advance.
Soluzione
If you want to call static block in the phtml file then please add below code.
<?php
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('YOUR_BLOCK_ID')
->toHtml();
?>
If you want to add it in the CMS page then please add below code.
{{block class="Magento\\Cms\\Block\\Block" block_id="YOUR_BLOCK_ID"}}
And if you want to add through XML then please add below code.
<referenceContainer name="content">
<block class="Magento\Cms\Block\Block" name="YOUR_BLOCK_ID">
<arguments>
<argument name="block_id" xsi:type="string">YOUR_BLOCK_ID</argument>
</arguments>
</block>
</referenceContainer>
Happy Coding.
Altri suggerimenti
You can add in footer_links block
<referenceBlock name="footer_links">
<block class="Magento\Framework\View\Element\Html\Link\Current" ifconfig="catalog/seo/search_terms" name="search-term-popular-link">
<arguments>
<argument name="label" translate="true" xsi:type="string">Search Terms</argument>
<argument name="path" xsi:type="string">search/term/popular</argument>
</arguments>
</block>
</referenceBlock>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange