为了让不同的view以相同的布局进行显示,我们可以编写布局模板文件,并以layout.phtml为名称进行保存,并在index.php中指定这个文件所在的位置。
require_once'Zend/Layout.php';
Zend_Layout::startMvc(array('layoutPath'=>'../application/default/layouts'));
在布局文件中,我们可以指定网页需要使用的样式文件,JavaScript脚本文件。
<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>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号