Zend Framework之Layout

巴扎黑
Release: 2016-11-10 11:03:41
Original
893 people have browsed it

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(&#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>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template