Magento 2: How to insert a custom phtml file in a static block
-
15-04-2021 - |
Pergunta
I need to insert a phtml file in a static block. The Location of the file is
app/design/frontend/Pearl/weltpixel_custom/edu/custom.phtml
I use "weltpixel_custom" as my child theme
This is the code in the static block:
{{block class="Magento\Framework\View\Element\Template" template="weltpixel_custom::edu/test.phtml"}}
I got the following error: Invalid template file: 'weltpixel_custom::edu/test.phtml' in module: '' block's name: 'magento\framework\view\element\template_0'
Do you a solution? In Magento 1.9 it worked with this code:
{{block type="core/template" template="edu/test.phtml"}}
and following file location:
app/design/frontend/ultimo/edu/template/edu
Thank you for helping!
Solução
You have called it wrong way. "weltpixel_custom" is a child theme of "weltpixel" , this is not any module so you have to move this "custom.phtml" file in any of the module like below,
path - app/design/frontend/Pearl/weltpixel_custom/Magento_Catalog/edu/custom.phtml
Like above you have to move any of the other module. I have moved it in Magento_Catalog module.
After that you have to call like below
{{block class="Magento\Framework\View\Element\Template" template="Magento_Catalog::edu/test.phtml"}}