Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Magento 2.0: How to add static block in a page template

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 422
    Comment on it

    In order to add static block in page (.phtml) template. Follow the steps below:

    Display Static Block in Phtml file & CMS page.

    In XML File:

    <referenceContainer name="content">
    <block class="Magento\Cms\Block\Block" name="block_identifier">
    <arguments>
    <argument name="block_id" xsi:type="string">block_identifier</argument>
    </arguments>
    </block>
    </referenceContainer>

    In Phtml File write the following code:

    <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>

    In CMS Content just write the following line:

    {{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}

     

    Now its all done!. Static block has been added

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: