cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2: Call phtml path from frontend folder

SOLVED

Magento 2: Call phtml path from frontend folder

This code below is used to call the template from /app/code/ module.

 

$gridHtml = $block->getLayout()->createBlock(
'\Magento\Framework\View\Element\Template',
'custom_grid_new'
)->setTemplate('Magento_CustomGrid::product/view/templates/grid.phtml')
->toHtml();

How to set the template from following path

 

/app/design/frontend/Magento/luma/Custom_Grid/templates/grid1.phtml

tried this above in above code, but is not working.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2: Call phtml path from frontend folder

Hello @mr_bukhari 

 

Try below code :

$gridHtml = $block->getLayout()->createBlock(
'\Magento\Framework\View\Element\Template',
'custom_grid_new'
)->setTemplate('Magento_CustomGrid::grid.phtml')
->toHtml();

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

View solution in original post

1 REPLY 1

Re: Magento 2: Call phtml path from frontend folder

Hello @mr_bukhari 

 

Try below code :

$gridHtml = $block->getLayout()->createBlock(
'\Magento\Framework\View\Element\Template',
'custom_grid_new'
)->setTemplate('Magento_CustomGrid::grid.phtml')
->toHtml();

Hope it helps !

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy