微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Zend Framework基本页面布局分析

本文实例讲述了Zend Framework基本页面布局方法分享给大家供大家参考,具体如下:

Zend Framework 的页面布局模块——Zend_Layout——既可以跟 MVC 一起使用,也可以单独使用。本文只讨论与 MVC 一起使用的情况。

1、布局脚本

在 application/views 下创建一个 layouts 的文件夹。主布局脚本 layout.phtml 代码如下:

rush:PHP;"> doctype('XHTML1_STRICT') ?> headTitle() ?> headLink()->appendStylesheet("/styles/main.css"); // add more links ... ?> headLink() ?>
partial('leftcolumn.phtml') ?>
layout()->content ?>
partial('footer.phtml') ?>

除了 layout.phtml 之外,还需要编写 header.phtml,leftcolumn.phtml,footer.phtml,以及 main.css 等文件。 Zend Framework 的文档中用一个视图表示了页面布局的应用。

2、设置页面布局

在 MVC 下设置页面布局非常简单,编辑 html/index.PHP,加入下面两行代码

rush:PHP;"> /** Setup layout */ require_once 'Zend/Layout.PHP'; Zend_Layout::StartMVC($rootPath . '/application/views/layouts');

注意:在启动页面布局后,要调整已有的各个页面,把不需要的 html 元素,如

<body> 等去掉。另外,可以通过 $this->headTitle() 来设置<a href="https://www.jb51.cc/tag/yemian/" target="_blank" class="keywords">页面</a>的题头。</p> <p>改变<a href="https://www.jb51.cc/tag/yemian/" target="_blank" class="keywords">页面</a>的布局也很简单,只需在控制器中用下面的<a href="https://www.jb51.cc/tag/daima/" target="_blank" class="keywords">代码</a>即可:</p> <div class="jb51code"> <pre class="brush:php;"> $this->_helper->layout->setLayout('new_layout'); </pre> </div> <p>如果<a href="https://www.jb51.cc/tag/yige/" target="_blank" class="keywords">一个</a>控制器所有动作都使用同<a href="https://www.jb51.cc/tag/yige/" target="_blank" class="keywords">一个</a><a href="https://www.jb51.cc/tag/yemian/" target="_blank" class="keywords">页面</a>布局,可以通过控制器的初始化<a href="https://www.jb51.cc/tag/hanshu/" target="_blank" class="keywords">函数</a>来设置:</p> <div class="jb51code"> <pre class="brush:php;"> public function init() { parent::init(); $this->_helper->layout->setLayout('new_layout'); } </pre> </div> <p>更多关于zend相关<a href="https://www.jb51.cc/tag/neirong/" target="_blank" class="keywords">内容</a>感兴趣的读者可查看本站专题:《<a target="_blank" href="//www.jb51.cc/Special/546.htm">Zend FrameWork框架入门教程</a>》、《<a target="_blank" href="//www.jb51.cc/Special/155.htm">php优秀开发框架总结</a>》、《<a target="_blank" href="//www.jb51.cc/Special/386.htm">Yii框架入门及常用技巧总结</a>》、《<a target="_blank" href="//www.jb51.cc/Special/39.htm">ThinkPHP入门教程</a>》、《<a target="_blank" href="//www.jb51.cc/Special/43.htm">php面向对象程序设计入门教程</a>》、《<a target="_blank" href="//www.jb51.cc/Special/84.htm">php+mysql数据库操作入门教程</a>》及《<a target="_blank" href="//www.jb51.cc/Special/231.htm"><a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a>常见<a href="https://www.jb51.cc/tag/shujuku/" target="_blank" class="keywords">数据库</a>操作技巧汇总</a>》</p> <p>希望本文所述对大家基于Zend Framework框架的<a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a>程序设计有所帮助。</p><ins class="adsbygoogle" style="display:inline-block;width:780px;height:90px" data-ad-client="ca-pub-4605373693034661" data-ad-slot="4286417769"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <p>原文地址:https://www.jb51.cc/php/20160.html</p> <p class="small text-muted">版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。</p> </div><div class="topcard-tags"><a href="https://www.jb51.cc/tag/Framework/" class="tag_link" target="_blank">Framework</a><a href="https://www.jb51.cc/tag/Zend/" class="tag_link" target="_blank">Zend</a><a href="https://www.jb51.cc/tag/yemianbuju/" class="tag_link" target="_blank">页面布局</a></div><ul class="list-group"> <li class="list-group-item"><a href="https://www.jb51.cc/php/20161.html" title="Zend Framework连接Mysql数据库实例分析">上一篇:Zend Framework连接Mysql数据库实例</a><a href="https://www.jb51.cc/php/20159.html" title="Zend Framework缓存Cache用法简单实例" class="text-muted pull-right">下一篇:Zend Framework缓存Cache用法简单实</a> </li> </ul> </div> </div> </div> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <h4>相关推荐</h4> <hr /> <div class="list_con"> <a href="https://www.jb51.cc/php/4739043.html" title="vue+thinkphp5实现微信扫码支付(NATIVE支付)"><div class="title">vue+thinkphp5实现微信扫码支付(NATIVE支付)</div> <div class="summary">统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返回预支付订单号的接口,目前微信支付所有场景均使用这一接口。下面介绍的是其中NATIVE的支付实现流程与PC端实现扫码支付流程</div> <time class="summary">作者:我恨bug 时间:2024-07-30</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4739042.html" title="uniapp+thinkphp5实现微信扫码支付(APP支付)"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2024/07-30/10/32d06eca1830b39e35547ff639b7b95b.png" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">uniapp+thinkphp5实现微信扫码支付(APP支付)</div> <div class="summary">统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返回预支付订单号的接口,目前微信支付所有场景均使用这一接口。下面介绍的是其中APP的支付的配置与实现流程</div> <time class="summary">作者:我恨bug 时间:2024-07-30</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4739041.html" title="uniapp+thinkphp5实现微信登录"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2024/07-30/10/3d907355e295604aef536bba5b45dd7d.png" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">uniapp+thinkphp5实现微信登录</div> <div class="summary">前言 之前做了微信登录,所以总结一下微信授权登录并获取用户信息这个功能的开发流程。 配置 1.首先得在微信公众平台申请一下微信小程序账号并获取到小程序的AppID和AppSecret https://mp.weixin.qq.com/cgi-bin/loginpage?url=%2Fwxamp%2F</div> <time class="summary">作者:我恨bug 时间:2024-07-30</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4739040.html" title="【PHP】关于fastadmin框架中使用with进行连表查询时setEagerlyType字段的理解"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2024/07-30/10/fc29e4e4eba385bc042444571f518ef6.png" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">【PHP】关于fastadmin框架中使用with进行连表查询时setEagerlyType字段的理解</div> <div class="summary">FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一款开源且免费商用的后台开发框架,它基于ThinkPHP和Bootstrap两大主流技术构建的极速后台开发框架,它有着非常完善且强大的功能和便捷的开发体验,使我逐渐喜欢上了它。</div> <time class="summary">作者:我恨bug 时间:2024-07-30</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4739039.html" title="【workerman】uniapp+thinkPHP5使用GatewayWorker实现实时通讯"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2024/07-30/10/e6971fb86d3ee30a4466e87826da43d8.png" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">【workerman】uniapp+thinkPHP5使用GatewayWorker实现实时通讯</div> <div class="summary">之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛,就离不开通讯了,然后我就想到了长连接。这里本人用的是GatewayWorker框架。</div> <time class="summary">作者:我恨bug 时间:2024-07-30</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4739038.html" title="uniapp+thinkphp5实现微信支付(JSAPI支付)"><div class="title">uniapp+thinkphp5实现微信支付(JSAPI支付)</div> <div class="summary">统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返回预支付订单号的接口,目前微信支付所有场景均使用这一接口。下面介绍的是其中JSAPI的支付实现流程</div> <time class="summary">作者:我恨bug 时间:2024-07-30</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4676831.html" title="服务器优化必备:深入了解PHP8底层开发原理"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2023/09-11/01/a3322fb8f7853a71e573cffcd7960431.jpg" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">服务器优化必备:深入了解PHP8底层开发原理</div> <div class="summary">服务器优化必备:深入了解PHP8底层开发原理</div> <time class="summary">作者:编程之家 时间:2023-09-11</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4676830.html" title="Golang的网络编程:如何快速构建高性能的网络应用?"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2023/09-11/01/891786da89034c5ca51a30e1cd0b54ec.jpg" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">Golang的网络编程:如何快速构建高性能的网络应用?</div> <div class="summary">Golang的网络编程:如何快速构建高性能的网络应用?</div> <time class="summary">作者:编程之家 时间:2023-09-11</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4676829.html" title="Golang和其他编程语言的对比:为什么它的开发效率更高?"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2023/09-11/01/b4ba3ff14a96ec8962f292ee854b63d9.jpg" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">Golang和其他编程语言的对比:为什么它的开发效率更高?</div> <div class="summary">Golang和其他编程语言的对比:为什么它的开发效率更高?</div> <time class="summary">作者:编程之家 时间:2023-09-11</time> </a> </div><div class="list_con"> <a href="https://www.jb51.cc/php/4676828.html" title="PHP8底层开发原理揭秘:如何利用新特性创建出色的Web应用"><img class="lazy" src="https://www.jb51.cc/images/np.jpg" data-original="https://www.jb51.cc/res/2023/09-11/01/6932d37a1c1dfaec001b928e40ac7216.jpg" title="" width="160" height="90" style="float:right;margin-left:30px;" /><div class="title">PHP8底层开发原理揭秘:如何利用新特性创建出色的Web应用</div> <div class="summary">PHP8底层开发原理揭秘:如何利用新特性创建出色的Web应用</div> <time class="summary">作者:编程之家 时间:2023-09-11</time> </a> </div></div> </div> </div> </div> <div class="col-sm-12 col-md-12 col-lg-3"> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <!-- jb51-article-300x600 --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:600px" data-ad-client="ca-pub-4605373693034661" data-ad-slot="7541177540"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <!-- row end --> <!-- row --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card" style="padding:20px;"> <label class="main-content-label ">小编推荐</label><div class="entry-img"><img src="https://www.jb51.cc/res/2023/06-29/12/fa513c17761076a6649593e2bd17f268.jpg" height="150" width="100%"><div class="entry-wrap"><a href="https://www.jb51.cc/mp/4606010.html" title="苹果市值2025年有望达4万亿美元" >苹果市值2025年有望达4万亿美元</a> </div></div><ul class="n-list"><li><a href="https://www.jb51.cc/mp/4820372.html" title="iPadOS 18来了,iPad现在真的有“生产力”了吗?" >• iPadOS 18来了,iPad现在真的有“生产力</a></li><li><a href="https://www.jb51.cc/mp/4820371.html" title="谷歌日本整活:打造莫比乌斯外形键盘 正反都能用" >• 谷歌日本整活:打造莫比乌斯外形键盘 正</a></li><li><a href="https://www.jb51.cc/mp/4820370.html" title="天玑9400核心配置曝光,OV米均已采购,调教哪家强?" >• 天玑9400核心配置曝光,OV米均已采购,</a></li><li><a href="https://www.jb51.cc/mp/4820369.html" title="iPad和安卓Pad有什么区别?不用这三项功能省2000" >• iPad和安卓Pad有什么区别?不用这三项功</a></li><li><a href="https://www.jb51.cc/mp/4820368.html" title="松下全画幅镜头便携长焦70-300mm F4.5-5.6设计大揭秘" >• 松下全画幅镜头便携长焦70-300mm F4.5-</a></li><li><a href="https://www.jb51.cc/mp/4820367.html" title="停产Quest Pro、力推Quest 3S,Meta要让VR更下沉" >• 停产Quest Pro、力推Quest 3S,Meta要让</a></li><li><a href="https://www.jb51.cc/mp/4820366.html" title="RTX 4080/90要说再见!消息称英伟达11月开始全面停产断供" >• RTX 4080/90要说再见!消息称英伟达11月</a></li></ul> </div> </div> </div> <!-- row end --> <div class="row row-sm"> <div class="col-sm-12 col-md-12 col-lg-12"> <div class="card"> <label class="main-content-label ">热门标签<a href="https://www.jb51.cc/all" class="pull-right">更多</a> </label> <div class="topcard-tags"><a href="https://www.jb51.cc/tag/python/" title="python">python</a><a href="https://www.jb51.cc/tag/JavaScript/" title="JavaScript">JavaScript</a><a href="https://www.jb51.cc/tag/java/" title="java">java</a><a href="https://www.jb51.cc/tag/HTML/" title="HTML">HTML</a><a href="https://www.jb51.cc/tag/PHP/" title="PHP">PHP</a><a href="https://www.jb51.cc/tag/reactjs/" title="reactjs">reactjs</a><a href="https://www.jb51.cc/tag/C/" title="C#">C#</a><a href="https://www.jb51.cc/tag/Android/" title="Android">Android</a><a href="https://www.jb51.cc/tag/CSS/" title="CSS">CSS</a><a href="https://www.jb51.cc/tag/Nodejs/" title="Node.js">Node.js</a><a href="https://www.jb51.cc/tag/sql/" title="sql">sql</a><a href="https://www.jb51.cc/tag/rp/" title="r">r</a><a href="https://www.jb51.cc/tag/python3x/" title="python-3.x">python-3.x</a><a href="https://www.jb51.cc/tag/MysqL/" title="MysqL">MysqL</a><a href="https://www.jb51.cc/tag/jQuery/" title="jQuery">jQuery</a><a href="https://www.jb51.cc/tag/c4343/" title="c++">c++</a><a href="https://www.jb51.cc/tag/pandas/" title="pandas">pandas</a><a href="https://www.jb51.cc/tag/flutter/" title="Flutter">Flutter</a><a href="https://www.jb51.cc/tag/angular/" title="angular">angular</a><a href="https://www.jb51.cc/tag/IOS/" title="IOS">IOS</a><a href="https://www.jb51.cc/tag/django/" title="django">django</a><a href="https://www.jb51.cc/tag/linux/" title="linux">linux</a><a href="https://www.jb51.cc/tag/swift/" title="swift">swift</a><a href="https://www.jb51.cc/tag/typescript/" title="typescript">typescript</a><a href="https://www.jb51.cc/tag/luyouqi/" title="路由器">路由器</a><a href="https://www.jb51.cc/tag/JSON/" title="JSON">JSON</a><a href="https://www.jb51.cc/tag/luyouqishezhi/" title="路由器设置">路由器设置</a><a href="https://www.jb51.cc/tag/wuxianluyouqi/" title="无线路由器">无线路由器</a><a href="https://www.jb51.cc/tag/h3c/" title="h3c">h3c</a><a href="https://www.jb51.cc/tag/huasan/" title="华三">华三</a><a href="https://www.jb51.cc/tag/huasanluyouqishezhi/" title="华三路由器设置">华三路由器设置</a><a href="https://www.jb51.cc/tag/huasanluyouqi/" title="华三路由器">华三路由器</a><a href="https://www.jb51.cc/tag/diannaoruanjianjiaocheng/" title="电脑软件教程">电脑软件教程</a><a href="https://www.jb51.cc/tag/arrays/" title="arrays">arrays</a><a href="https://www.jb51.cc/tag/docker/" title="docker">docker</a><a href="https://www.jb51.cc/tag/ruanjiantuwenjiaocheng/" title="软件图文教程">软件图文教程</a><a href="https://www.jb51.cc/tag/C/" title="C">C</a><a href="https://www.jb51.cc/tag/vuejs/" title="vue.js">vue.js</a><a href="https://www.jb51.cc/tag/laravel/" title="laravel">laravel</a><a href="https://www.jb51.cc/tag/springboot/" title="spring-boot">spring-boot</a></div> </div> </div> </div> </div> </div> </div> <footer id="footer"> <div class="container" style="width:1440px;"> <div class="row hidden-xs"> <div class="col-sm-12 col-md-9 col-lg-9 site-link"> <ul class="list-inline"> <li>友情链接:</li><li><a href="https://ai.jb51.cc/" title="ai导航是编程之家旗下ai方向的ai资讯、ai工具类集合导航站。" target="_blank" rel="nofollow">ai导航</a></li></ul> <ul class="list-inline"> <li><a href="https://www.jb51.cc" title="编程之家">编程之家</a></li>-<li><a href="https://t5m44pq3f7.jiandaoyun.com/f/638ca61b7b079a000a5d2dd6" rel="nofollow" title="我要投稿" target="_blank">我要投稿</a></li>-<li><a target="_blank" rel="nofollow" href="https://t5m44pq3f7.jiandaoyun.com/f/638ca8c69ad234000a79561f" title="广告合作">广告合作</a></li>-<li><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=76874919&site=qq&menu=yes">联系我们</a></li>-<li><a href="https://www.jb51.cc/disclaimers.html" title="免责声明">免责声明</a></li>-<li><a href="https://www.jb51.cc/sitemap/all/index.xml" title="网站地图" target="_blank">网站地图</a></li> </ul> <div>版权所有 © 2018编程之家<a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">闽ICP备13020303号-8</a> </div> </div> <div class="col-sm-12 col-md-3 col-lg-3"><img src="https://www.jb51.cc/qrcode.jpg" width="90" alt="微信公众号搜索 “ 程序精选 ” ,选择关注!"> <div class="pull-right">微信公众号搜<span class="text-danger">"智元新知"</span>关注<br />微信扫一扫可直接关注哦!</div> </div> </div> </div> </footer> <script> (function () { var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(bp, s); })(); </script> <script src="https://www.jb51.cc/js/count.js"></script> </body> </html>