In magento 2 How to call phtml file in static block

强颜欢笑 提交于 2019-12-11 03:24:10

问题


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.


回答1:


try below code :

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



回答2:


You can try the following code -

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



回答3:


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"}}



来源:https://stackoverflow.com/questions/38887624/in-magento-2-how-to-call-phtml-file-in-static-block

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!