Get The Easiest Way To Call Phtml File In CMS Static Block In Magento 2
Earlier I posted the solution to call CMS static block in phtml file in Magento 2.
And today, the below code shows how to call Phtml file in CMS static block in Magento 2.
You can use this method to call the Phtml file on any page.
For example, you want to call an Instagram image on a page in your Magento 2 store.
You can add and control HTML code to be displayed in the frontend using CMS static blocks.
The Magento 2 has the MVC architecture where the Phtml files have the view part of the code while the block classes contain its related logic.
Method to call Phtml file in CMS static block in Magento 2:
1 |
{{block class="Magento\Framework\View\Element\Template" template="Vendor_Extension::myfile.phtml"}} |
Any doubts about the topic? If so, feel free to mention them in the Comments section below. I’d be happy to help you out.
Do share the post with fellow developers via social media.
Thank you.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
Prev
How to Pause Your Magento 2 Store In Google Search During Coronavirus Outbreak
How To Get The Data Of Shopping Cart Items, Subtotal, Grand Total, Billing & Shipping Address In Magento 2
Next