Display .phtml page in another .phtml page

℡╲_俬逩灬. 提交于 2019-12-11 12:15:47

问题


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(); ?>


来源:https://stackoverflow.com/questions/31382959/display-phtml-page-in-another-phtml-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!