简体   繁体   English

Magento在另一个phtml文件中包含phtml文件

[英]Magento include phtml file within another phtml file

I am making a custom home page for my magento website in a phtml file named home_banner.phtml, which in turn i have referenced in the CMS->Pages->Home Page content by the following code 我正在使用名为home_banner.phtml的phtml文件为magento网站创建自定义主页,而我又通过以下代码在CMS-> Pages-> Home内容中引用了该文件

{{block type="core/template" template="theme/home_banner.phtml"}}

In my home_banner.phtml I have called tags/popular.phtml to display the popular tags. 在我的home_banner.phtml中,我调用了tags / popular.phtml来显示流行标签。

<div class="last-posts-grid clearfix">

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

</div>

However the tags are not being displayed even though the anchor tag which says "view all tags" id getting called correctly. 但是,即使正确地调用了显示“查看所有标签”的锚标签,也不会显示标签。 The ul class="tags-list" is also visible in the page source but the tags themselves are not visible. ul class =“ tags-list”在页面源中也可见,但是标记本身不可见。 Any suggestions? 有什么建议么?

You made a small mistake in the template file. 您在模板文件中犯了一个小错误。 Your template file has to be as below: 您的模板文件必须如下所示:

<div class="last-posts-grid clearfix">

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

</div>

I tested this and its working fine.. Hope this helps.. 我对此进行了测试,并且工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM