【问题标题】:Best way to include page header/footer in zend framework using MVC使用 MVC 在 zend 框架中包含页眉/页脚的最佳方法
【发布时间】:2010-11-12 23:20:45
【问题描述】:

在使用 MVC 时在 zf 中包含页眉和页脚的最佳方法是什么?

目前我的引导程序中有这个:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap{
    static public function displayHeader(){
         return 'pageheader';   
    }
}

然后在控制器中我可以执行以下操作:

$this->view->header = Bootstrap::displayHeader();

有没有更好的方法来做到这一点?我可以将它与 render() 结合使用 displayHeader 生成所有必需的变量,然后使用 render() 加载 header.phtml 文件吗?

任何见解都会很棒!

【问题讨论】:

    标签: php model-view-controller zend-framework


    【解决方案1】:

    You put that into your layout.phtml

    <body>
        <?php echo $this->render('header.phtml') ?>
        <div id="nav"><?php echo $this->placeholder('nav') ?></div>
        <div id="content"><?php echo $this->layout()->content ?></div>
        <?php echo $this->render('footer.phtml') ?>
    </body>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      • 2019-04-24
      • 1970-01-01
      • 1970-01-01
      • 2016-04-26
      • 2010-09-15
      • 2014-04-10
      相关资源
      最近更新 更多