【问题标题】:Zend - How to include file in view like masterpae asp.net?Zend - 如何在 masterpae asp.net 等视图中包含文件?
【发布时间】:2013-05-23 10:19:26
【问题描述】:

我有这样的结构文件夹:

http://nx9.upanh.com/b4.s37.d4/3fd103509d1ac25ece02096b5e25a5f0_55810779.capture.png
(真的很抱歉,我的声望不够)

我想包含 2 个文件,即 public/shared/ 文件夹中的 header.phtml 和 footer.phtml 以查看默认模块,我使用以下代码:

<?php echo $this->partial('public/shared/header.phtml'); ?>

<h3>This is index.phtml</h3>

<?php echo $this->partial('public/shared/footer.phtml'); ?>

但我收到错误HTTP 500(内部服务器错误)。如果我只使用html代码,没有问题发生。

<h3>This is index.phtml</h3>

我可以在 CodeIgniter 框架中执行此操作,但我不知道如何在 Zend 框架中执行此操作。请帮我!非常感谢。

【问题讨论】:

    标签: php asp.net-mvc zend-framework master-pages


    【解决方案1】:

    您使用的是 ZF1 还是 2 ?在 ZF1 中,您需要将页眉和页脚放入位于 application/layouts/scripts/layout.phtml 的 layout.phtml 文件中。

    实际的 header.phtml 和 footer.phtml 应该放在 application/view/scripts 文件夹中,然后你可以这样做:

    布局.PHTML:

    <?php echo $this->partial('header.phtml') ?>
    
    // this bit will render the action content
    <?php print $this->layout()->content ?>
    
    <?php echo $this->partial('footer.phtml') ?>
    

    【讨论】:

    • 谢谢!我看到你的答案了。
    • 但是,我可以在哪里调用 layout.phtml?
    • 你不需要调用layout.phtml。引导程序应该管理它。你为什么不通读一两个教程?见akrabat.com/zend-framework-tutorial
    猜你喜欢
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-05
    • 2019-07-30
    • 1970-01-01
    相关资源
    最近更新 更多