簡體   English   中英

使用MVC在zend框架中包含頁面頁眉/頁腳的最佳方法

[英]Best way to include page header/footer in zend framework using MVC

使用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文件?

任何見識都會很棒!

您將其放入您的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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM