I need to call a phtml file within my cms page and it will not work.
this is the code in the cms page
{{block type="core/template" template="catalog/product/form-top.phtml"}}
fom-top.phtml basically opens a form but that does not matter. this code cause nothing past the header to be displayed.
any ideas on how to call a phtml file within a CMS page?
Except for displaying CMS block on CMS Page or CMS Block, showing it on category page there is an option to call CMS block programmatically using XML file. You need to replace "my_cmsblock_identifier" with your CMS block Identifier or ID (we recommend to use Identifier).
To call your phtml file at place of core(magento's) file, you need to follow: Firstly, create a xml file with the controller name, on which page you want to override. For example : here we override checkout/cart/index controller page file.
View the source of your webpage and scroll to the bottom to see a php error.
form-top.phtml gets called but there is a php error inside which fails. The error might happen in an invisible div that's why you don't see it the normal way.
Replace your line with following code
{{block class="Magento\Framework\View\Element\Template" template="catalog/product/form-top.phtml"}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With