【问题标题】:Magento include phtml file within another phtml fileMagento 在另一个 phtml 文件中包含 phtml 文件
【发布时间】:2015-02-09 05:05:06
【问题描述】:

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

{{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>

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

【问题讨论】:

    标签: tags magento-1.9 php


    【解决方案1】:

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

    <div class="last-posts-grid clearfix">
    
         <?php echo $this->getLayout()->createBlock('tag/popular')->setTemplate('tag/popular.phtml')->toHtml(); ?>
    
    </div>
    

    我对此进行了测试并且工作正常..希望这会有所帮助..

    【讨论】:

    • 如何在首页调用反馈表单phtml文件?
    猜你喜欢
    • 2014-04-28
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多