`
禹爸爸
  • 浏览: 79931 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

Zend Framework之Layout

    博客分类:
  • PHP
阅读更多

为了让不同的View以相同的布局进行显示,我们可以编写布局模板文件,并以layout.phtml为名称进行保存,并在Index.php中指定这个文件所在的位置。

  1. require_once'Zend/Layout.php';
  2. Zend_Layout::startMvc(array('layoutPath'=>'../application/default/layouts'));

在布局文件中,我们可以指定网页需要使用的样式文件,JavaScript脚本文件。

  1. <html>
  2. <head>
  3. <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
  4. <?php
  5. $request=Zend_Controller_Front::getInstance()->getRequest();
  6. $this->headTitle('视图中使用视图')
  7. ->headTitle($request->getModuleName())
  8. ->headTitle($request->getActionName())
  9. ->headTitle($request->getControllerName())
  10. ->setSeparator('|');
  11. echo$this->headTitle();
  12. $this->headLink()->appendStylesheet($this->baseUrl."/css/style.css")
  13. ->appendStylesheet($this->baseUrl."/css/demo.css");
  14. echo$this->headLink();
  15. $this->headScript()->appendFile($this->baseUrl."/js/jquery-1.2.6.js")
  16. ->appendFile($this->baseUrl."/js/jquery.datePicker.js")
  17. ->appendFile($this->baseUrl."/js/demo.js");
  18. echo$this->headScript();
  19. ?>
  20. </head>
  21. <body>
  22. <divid='bodywrapper'>
  23. <divid='header'>
  24. <?phpecho$this->partial('header.phtml','default');?>
  25. </div>
  26. <divid='sidebar'>
  27. <?phpecho$this->partial('leftside.phtml','default');?>
  28. </div>
  29. <divid='midcontent'>
  30. <?phpecho$this->layout()->content;?>
  31. </div>
  32. <divid='footer'>
  33. <?phpecho$this->partial('footer.phtml','default');?>
  34. </div>
  35. </div>
  36. </body>
  37. </html>

版权声明:本文为博主原创文章,未经博主允许不得转载。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics