Magento 2: How to call any template block from phtml file?

 

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

In Magento 2.x, it’s slightly different.

Below is the code to call/print a custom template block in another template file in Magento 2.

Suppose, you want to call a template block (helloworld.phtml) of module Chapagain_HelloWorld, then you should write the following code:

If you would like to call template block in CMS static Block or CMS Page in Magento 2, then you can simply write the following code:

Let’s take the same example as above (calling helloworld.phtml of module Chapagain_HelloWorld).

Leave a Comment