In order to display different Views with the same layout, we can write a layout template file, save it as layout.phtml, and specify the location of this file in Index.php.
require_once'Zend/Layout.php';
Zend_Layout::startMvc(array('layoutPath'=>'../application/default/layouts'));
In the layout file, we can specify the web page needs Style files and JavaScript script files used.
<html> <head> <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/> <?php $request=Zend_Controller_Front::getInstance()->getRequest(); $this->headTitle('视图中使用视图') ->headTitle($request->getModuleName()) ->headTitle($request->getActionName()) ->headTitle($request->getControllerName()) ->setSeparator('|'); echo$this->headTitle(); $this->headLink()->appendStylesheet($this->baseUrl."/css/style.css") ->appendStylesheet($this->baseUrl."/css/demo.css"); echo$this->headLink(); $this->headScript()->appendFile($this->baseUrl."/js/jquery-1.2.6.js") ->appendFile($this->baseUrl."/js/jquery.datePicker.js") ->appendFile($this->baseUrl."/js/demo.js"); echo$this->headScript(); ?> </head> <body> <divid='bodywrapper'> <divid='header'> <?phpecho$this->partial('header.phtml','default');?> </div> <divid='sidebar'> <?phpecho$this->partial('leftside.phtml','default');?> </div> <divid='midcontent'> <?phpecho$this->layout()->content;?> </div> <divid='footer'> <?phpecho$this->partial('footer.phtml','default');?> </div> </div> </body> </html>