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?

0

2 Answers 2

0

you can call it like this.

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

in cms -> homepage-> content

1
  • and if i want to add it on product Jun 8, 2017 at 13:18
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"}} 

Not the answer you're looking for? Browse other questions tagged or ask your own question.