0

How to call static block in front end of site? Exact steps to display it by taking example of identifier: 'footer-link'

How can I do it?

Jarnail S
  • 4,697
  • 30
  • 45
  • 80
ana.coman93
  • 341
  • 2
  • 15

2 Answers2

0

you can call it like this.

{{block type="cms/block" block_id="footer-link"}} 

in cms -> homepage-> content

Nikunj Vadariya
  • 4,037
  • 1
  • 20
  • 30
0

You can reference static blocks within xml for pages like product pages:

    <referenceBlock name="product.info.main">
        <block class="Magento\Cms\Block\Block" name="product.staticblock" as="staticblock" >
            <arguments>
                <argument translate="true" name="title" xsi:type="string">Footer Links</argument>
                <argument name="block_id" xsi:type="string">footer-link</argument>
            </arguments>
        </block>
    </referenceBlock>

Various blocks can be referenced depending on where you want your block to display.

Above XML should go in your theme within:

'Magento_Catalog/layout/catalog_product_view.xml'

Or when within a module:

'view/frontend/layout/catalog_product_view.xml'

The below can reference a static block within phtml file within template:

echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('footer-links')->toHtml();

As suggested by Nikunj Vadariya to include static block from CMS use:

{{block type="cms/block" block_id="footer-link"}} 
harri
  • 5,465
  • 6
  • 44
  • 100