Magento include phtml file within another phtml file

Magento include phtml file within another phtml file

In this post we will show you Magento include phtml file within another phtml file, hear for Magento include phtml file within another phtml file we will give you demo and example for implement.

For Magento include phtml file within another phtml file, you need change block type core/template to tag/yourtemplatename.

<?php echo $this->getLayout()->createBlock('tag/yourtemplatename')->setTemplate('tag/your_template_name.phtml')->toHtml(); ?>

OR you can use this

give a name of block

{{block type="core/template" template="theme/home_page_banner.phtml"  name="setmyanme"}}

then

by using xml reference include tags/your_template_name.phtml

create local.xml at app/design/frontend/[youupackage]/[yourtemplate]/layout

put this code

<?xml version="1.0"?>
<layout version="0.1.0">
<cms_index_index translate="label">
<reference name="setmyanme">
<block type="tag/yourtemplatename" name="home_tag_template" template="tag/your_template_name.phtml"/>
</reference>
</cms_index_index>
</layout>

and put below code at home_page_banner.phtml

echo $this->getChildHtml('home_tag_template');

Hope this code and post will helped you for implement Magento include phtml file within another .phtml file. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve onlincode. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs onlincode.org

Leave a Comment

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

  +  6  =  15

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US