繁体   English   中英

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

[英]Magento include phtml file within another phtml file

我正在使用名为home_banner.phtml的phtml文件为magento网站创建自定义主页,而我又通过以下代码在CMS-> Pages-> Home内容中引用了该文件

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

在我的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>

但是,即使正确地调用了显示“查看所有标签”的锚标签,也不会显示标签。 ul class =“ tags-list”在页面源中也可见,但是标记本身不可见。 有什么建议么?

您在模板文件中犯了一个小错误。 您的模板文件必须如下所示:

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

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

</div>

我对此进行了测试,并且工作正常。

暂无
暂无

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

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