Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call a PHTML file within a CMS page Magento

Tags:

php

magento

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?

like image 799
molleman Avatar asked Mar 07 '12 13:03

molleman


People also ask

How do you call a CMS block in xml file in magento 2?

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).

How do I override a Phtml file in magento2?

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.


2 Answers

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.

like image 63
balrok Avatar answered Nov 12 '22 15:11

balrok


Replace your line with following code

{{block class="Magento\Framework\View\Element\Template" template="catalog/product/form-top.phtml"}}
like image 30
Pratik Bharodiya Avatar answered Nov 12 '22 14:11

Pratik Bharodiya