简体   繁体   中英

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

What is the best way to include a page header and footer within zf whilst using MVC?

At the moment I have this in my bootstrap:

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

and then within a controller I can do something like:

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

Is there a better way to do this? Could I perhaps combine it with render() and use the displayHeader to generate all the required variables then use render() to load the header.phtml file?

Any insight would be great!

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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