How To Call Core Template File In Magento



When we are dealing with the custom HTML integration into the Magento, sometimes we wants to call core template file in Magento or we wants to call the .phtml file into the .phtml. It is very important and easy to call the .phtml into the .phtml, here in this post I have described how we can do it.

There is two method to call the Core Template file in Magento

Method 1 : For calling a core template file in .phtml file

I have created a .phtml file named as newfooterchanges.phtml and putted it under the custom folder, means app/design/frontend/default/your_custom_theme/template/custom

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('custom/newfooterchanges.phtml')->toHtml(); ?>

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('Your_Folder_Name/yourfile.phtml')->toHtml(); ?>

Method 2 : You can call this file in the CMS page by using the admin panel, just navigate to the CMS > Pages and select the page and now use the code below to load the file

{{block type="core/template" template="Your_Folder_Name/yourfile.phtml"}}

You have done and check your CMS page or the custom page.

Hope it helps, Thanks for reading.