cancel
Showing results for 
Search instead for 
Did you mean: 

How to create new phtml file in luma theme Magento 2 and call in cms page?

Highlighted

How to create new phtml file in luma theme Magento 2 and call in cms page?

Need to create one .phtml file and call in cms page because of the frontend view and HTML check.

3 REPLIES 3
Highlighted

Re: How to create new phtml file in luma theme Magento 2 and call in cms page?

Hello @Ashish_k_php ,

 

Please paste this code in your CMS page to get that block inside that CMS :

{{block class="Magento\Framework\View\Element\Template" template="[VendorName]_[ModuleName]::[YourTemplateFileLocation].phtml"}} 

change block class if your phtml file is dependent on any class.

 

Problem Solved ? Click on 'Kudos' & Accept as Solution to encourage to write more answers !
Highlighted

Re: How to create new phtml file in luma theme Magento 2 and call in cms page?

Hi @Ashish_k_php ,

 

You can create phtml file in luma theme in one of the module directory.

Example Magento_Theme folder have home_banner.phtml file.

{{block class="Magento\Framework\View\Element\Template" name="custom-content" template="Magento_Theme::home_banner.phtml"}}

You can change the block class if your phtml is 

Dependent on some block class.

Clear the magento cache.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Highlighted

Re: How to create new phtml file in luma theme Magento 2 and call in cms page?

Hi @Ashish_k_php 

 

Try to add new phtml file withing your custom module:

app/design/frontend/{vendor}/{theme}/Vendor_Module/templates/{file.phtml}

And call with in cms page using below code:

{{block class="Magento\Framework\View\Element\Template" name="test_file" template="Vendor_Module::html/test.phtml"}}
 
Problem Solved? Please Click on 'Accept as Solution!'