日期:2014-05-20 浏览次数:20779 次
在application目录下创建layout目录,并在layout目录下创建auth_layout.phtml。(默认布局模板是layout.phtml?)
?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php echo $this->headTitle(); ?> </head> <body> <h1>Hi I am here!</h1> <?php echo $this->layout()->content; ?> </body> </html>?
?
在application/configs/application.ini里加上设置
resources.layout.layoutpath = APPLICATION_PATH "/layouts"
?
在Bootstrap.php添加如下代码:
?
protected function _initViewHelpers() { Zend_Layout::startMvc(); $view = Zend_Layout::getMvcInstance()->getView(); $view->doctype('XHTML1_STRICT'); $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8'); $view->headTitle()->setSeparator(' - '); $view->headTitle('Zend Framework Tutorial'); }?
?
在IndexController->indexAction方法里添加代码,这样可以给action选择一个布局。
?
$this->_helper->layout->setLayout('auth_layout');
?