Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to creat and call static block in magento 2


How to create Magento Static block and how to call CMS page, phtml file and XML file.

Please follow example code.
________________________________________________________________________________

How To create Static Block

Step 1 : Content > Blocks


Step 2 : Click to Add New Block

Step 3 : Enter your Block name ID name and save block



How to call statick block in magento 2

Magento 2 static block call in phtml file.

 getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('example-name')->toHtml();?>  


Magento 2 static block call in CMS page

 {{block class="Magento\\Cms\\Block\\Block" block_id="example-name"}}  


Magento 2 static block call in XML file

 


example-name









This post first appeared on Smita-tech, please read the originial post: here

Share the post

How to creat and call static block in magento 2

×

Subscribe to Smita-tech

Get updates delivered right to your inbox!

Thank you for your subscription

×