Zend Framework之Layout

巴扎黑
发布: 2016-11-10 11:03:41
原创
854 人浏览过

为了让不同的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(&#39;视图中使用视图&#39;)
->headTitle($request->getModuleName())
->headTitle($request->getActionName())
->headTitle($request->getControllerName())
->setSeparator(&#39;|&#39;);
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=&#39;bodywrapper&#39;>
<divid=&#39;header&#39;>
<?phpecho$this->partial(&#39;header.phtml&#39;,&#39;default&#39;);?>
</div>
<divid=&#39;sidebar&#39;>
<?phpecho$this->partial(&#39;leftside.phtml&#39;,&#39;default&#39;);?>
</div>
<divid=&#39;midcontent&#39;>
<?phpecho$this->layout()->content;?>
</div>
<divid=&#39;footer&#39;>
<?phpecho$this->partial(&#39;footer.phtml&#39;,&#39;default&#39;);?>
</div>
</div>
</body>
</html>
登录后复制


相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!