Call a PHTML File within a CMS Page

A very common thing when you create a CMS page is that you sometimes need to include / call a phtml template file. Let's see how you can easily do that.

Navigate to Magento admin under Content → Pages, create a new one and add the following code to the page content like in the screen below.

The Magento\Framework\View\Element\Template class is the default magento block class. This class can be replaced with your own block class if is needed. Same for the template file with your own template file. In our example our template file is located under /app/code/MageVision/Blog11/view/frontend/templates/view.phtml

In our phtml file we just add a simple text to display.

Feel free to share this post and ask your questions in the comments below.

Till next time!