Categories
Magento Developer Magento Expert Magento Website Development

Call a phtml file in another phtml file, xml layout, static block and cms page?

Magento experts techniques are as follows.

Lets say my custom file path is

app/design/frontend/{Package}/{theme}/Magento_Theme/templates/html/test.phtml

calling in xml layout file

<block class=”Magento\Framework\View\Element\Template” name=”test_file” template=”Magento_Theme::html/test.phtml”/>

Calling in blocks and cms pages

{{block class=”Magento\Framework\View\Element\Template” name=”test_file” template=”Magento_Theme::html/test.phtml”}}

Calling in any phtml file

<?php echo $this->getLayout()->createBlock(“Magento\Framework\View\Element\Template”)->setTemplate(“Magento_Theme::html/test.phtml”)->toHtml();?>

 

Leave a Reply

Your email address will not be published. Required fields are marked *