Suryakant Chavan
Suryakant Chavan

Reputation: 41

In magento 2 How to call phtml file in static block

I have created extension in magento 2 and i want to call content.phtml file from static block (from admin panel). My content template file location is

C:\xampp\htdocs\Magento2\app/code\Surya\Slider\view\frontend\templates\content.phtml

where, magento2 is my project folder, Surya is vendor and Slider is my extension name. I want to call content.phtml file on homepage through static block.

For that I have created one static block called as "slider". Also, i have created widget. But i want to call content.phtml file in static block.

Upvotes: 2

Views: 4941

Answers (3)

sagar sapkota
sagar sapkota

Reputation: 153

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:

The skeleton code to understand :

{{block class="<vendor_name>\<module_name>\Block\<module_name>" name="<your_block_name>" template="<vendor_name>_<module_name>::<tempate_directory>/content.phtml"}}

Exact code :

{{block class="Surya\Slider\Block\Slider" name="slider" template="Surya_Slider::content.phtml"}}

Upvotes: 1

Swapna Taru
Swapna Taru

Reputation: 688

You can try the following code -

{{block class="Surya\Slider\Block\Slideshow" template="Surya_Slider::content.phtml"}} 

Upvotes: 1

Rohit Gupta
Rohit Gupta

Reputation: 41

try below code :

{{block class="Surya\Slider\Block\Slideshow" template="Surya_Slider::content.phtml"}} 

Upvotes: 2

Related Questions