Zend Framework教程之Zend_Layout布局助手详解

本文实例讲述了Zend Framework教程之Zend_Layout布局助手。分享给大家供大家参考,具体如下:

一、作用

布局的作用和模版的作用类似。可以认为是把网站通用、公共的部分拿出来作为通用的页面框架。例如一个基本的web页面,可能页面的头和尾都是一样,不一样的可能只是内容body部分不一样,可以把公共的部分做成模版。不仅可以提高开发效率,也为后期的维护带来方便。

二、使用

这里举一个简单的例子。

首先用zend studio创建一个基本的zend framework项目:layout_demo1

结构大概如下“

├─.settings ├─application │ ├─configs │ ├─controllers │ ├─models │ └─views │ ├─helpers │ └─scripts │ ├─error │ └─index ├─docs ├─library ├─public └─tests ├─application │ └─controllers └─library

1.加入layout功能

应用配置文件/layout_demo2/application/configs/application.ini,加入如下配置

rush:bash;"> resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 0 resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" [staging : production]

2.相应的目录和布局模版文件

/layout_demo2/application/layouts/scripts/layout.phtml

├─application │ ├─configs │ ├─controllers │ ├─layouts │ │ └─scripts │ ├─models │ └─views

layout.html类似如下:

rush:xhtml;"> <Meta http-equiv="Content-Type" content="text/html;charset=utf-8"> my app

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...