Yii Framework 开发教程(13) UI 组件 ContentDecorator示例
来源:互联网 发布:华丽上班族电影知乎 编辑:程序博客网 时间:2024/06/05 11:23
和Java Swing中类似Yii Framework 中的Layout 也允许嵌套,这是通过CContentDecorator来实现的,不过代码中并不需要直接使用CContentDecorator ,而是在定义layout使用
- $this->beginContent('path/to/view');
- // ... content to be decorated
- $this->endContent();
其中view 为另外一个布局。
本例定义四个Layout,一个嵌套一个:
- ///main.php
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title><?php echo Yii::app()->name; ?></title>
- </head>
- <body>
- <h1>Widget Demo</h1>
- <?php echo $content; ?>
- </body>
- </html>
- ///row1.php
- <?php $this->beginContent('/layouts/row2'); ?>
- <div>
- <?php echo $content; ?>
- </div>
- <p />
- <div>
- <?php echo 'row1 part'; ?>
- </div>
- <?php $this->endContent(); ?>
- //row2.php
- <?php $this->beginContent('/layouts/row3'); ?>
- <div>
- <?php echo $content; ?>
- </div>
- <p />
- <div>
- <?php echo 'row2 part'; ?>
- </div>
- <?php $this->endContent(); ?>
- ///row3.php
- <?php $this->beginContent('/layouts/main'); ?>
- <div>
- <?php echo $content; ?>
- </div>
- <p />
- <div>
- <?php echo 'row3 part'; ?>
- </div>
- <?php $this->endContent(); ?>
显示结果如下:
本例下载
0 0
- Yii Framework 开发教程(13) UI 组件 ContentDecorator示例
- Yii Framework 开发教程(13) UI 组件 ContentDecorator示例
- Yii Framework 开发教程(11) UI 组件 ActiveForm示例
- Yii Framework 开发教程(12) UI 组件 ClipWidget示例
- Yii Framework 开发教程(14) UI 组件 MaskedTextField示例
- Yii Framework 开发教程(15) UI 组件 MultiFileUpload示例
- Yii Framework 开发教程(16) UI 组件 StarRating示例
- Yii Framework 开发教程(17) UI 组件 TabView示例
- Yii Framework 开发教程(18) UI 组件 TextHighlighter示例
- Yii Framework 开发教程(19) UI 组件 TreeView示例
- Yii Framework 开发教程(20) UI 组件 Captcha示例
- Yii Framework 开发教程(21) UI 组件 自定义Captcha示例
- Yii Framework 开发教程(11) UI 组件 ActiveForm示例
- Yii Framework 开发教程(12) UI 组件 ClipWidget示例
- Yii Framework 开发教程(14) UI 组件 MaskedTextField示例
- Yii Framework 开发教程(15) UI 组件 MultiFileUpload示例
- Yii Framework 开发教程(16) UI 组件 StarRating示例
- Yii Framework 开发教程(17) UI 组件 TabView示例
- Yii Framework 开发教程(11) UI 组件 ActiveForm示例
- C语言中的双向循环链表
- Yii Framework 开发教程(12) UI 组件 ClipWidget示例
- 赫夫曼编码
- 【OpenGL4.0】GLSL渲染语言入门与VBO、VAO使用:绘制一个三角形
- Yii Framework 开发教程(13) UI 组件 ContentDecorator示例
- IOS 发送邮件
- Yii Framework 开发教程(14) UI 组件 MaskedTextField示例
- IOS学习笔记——UITableView(一)
- Yii Framework 开发教程(15) UI 组件 MultiFileUpload示例
- SQL经典18题(不知道经不经典)
- i++ 和 ++i 效率的分析以及自定义类型的自增/自减运算符重载实例
- Yii Framework 开发教程(16) UI 组件 StarRating示例
- svn: Server sent unexpected return value (403 Forbidden) in response to CHECKOUT request for-解决方法