Display .phtml page in another .phtml page

2019-08-07 15:11发布

问题:

I have created a new.phtml page in catalog/product/new.phtml. which contain new/latest products. i have another .phtml page [product_slider.phtml]. i want to add new.phtml into product_slider.phtml is this possibale.?? how to use.. any idea.?

回答1:

To Display .phtml page in another .phtml page. you can use:

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('path after template dir/filename.phtml')->toHtml(); ?>


回答2:

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

You have to make sure block type , rather then core/template



回答3:

Answer

After Trying the code i got the solution.

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