yii-besic (六) 视图布局传值
2016-12-12 16:56
363 查看
(一)//调用视图层(布局)
public $layout='index';
//目录为/views/layouts/index.php
/*
*视图层内容为
*<!doctype html>
*<html lang="en">
*<head>
* <metacharset="UTF-8">
* <title>Document</title>
*</head>
*<body>
*<h1>1111</h1>
*<?=$content;?>
*</body>
*</html>
*/
//调用视图层(传值)
public function actionAbout(){
$data=array('name'=>'aaaaa');
return$this->render('index',$data);
}
//(二)调用中显示灵位一个视图(传值)
Index.php
<h1>hello index</h1>
<?php echo $this->reader(‘about’,array(‘name’=>’zhangsan’)) ?>
About.php
<h1>hello about</h1>
<?=$name?>
(三)数据块
Layout 文件
<?php if(isset($this->blocks[‘block1’])): ?>
<?=$this->blocks[‘block1’]?>
<?php else:?>
<H1>hellocommen</h1>
<?php endif; ?>
<?=$content;?>
Index.php
<h1>hello index</h1>
替换layout中的内容
<?php $this->beginBlock(‘block1’) ;?>
<h1>about</h1>
<?php $this->endBlock(); ?>
public $layout='index';
//目录为/views/layouts/index.php
/*
*视图层内容为
*<!doctype html>
*<html lang="en">
*<head>
* <metacharset="UTF-8">
* <title>Document</title>
*</head>
*<body>
*<h1>1111</h1>
*<?=$content;?>
*</body>
*</html>
*/
//调用视图层(传值)
public function actionAbout(){
$data=array('name'=>'aaaaa');
return$this->render('index',$data);
}
//(二)调用中显示灵位一个视图(传值)
Index.php
<h1>hello index</h1>
<?php echo $this->reader(‘about’,array(‘name’=>’zhangsan’)) ?>
About.php
<h1>hello about</h1>
<?=$name?>
(三)数据块
Layout 文件
<?php if(isset($this->blocks[‘block1’])): ?>
<?=$this->blocks[‘block1’]?>
<?php else:?>
<H1>hellocommen</h1>
<?php endif; ?>
<?=$content;?>
Index.php
<h1>hello index</h1>
替换layout中的内容
<?php $this->beginBlock(‘block1’) ;?>
<h1>about</h1>
<?php $this->endBlock(); ?>
相关文章推荐
- yii-besic (五)视图
- yii视图布局文件
- 关于后盾网yii框架的学习小结(2)--创建控制器,视图,布局等
- Yii之布局文件、显示其他视图、数据块
- yii2视图(布局)中各种函数总结报告及使用场景
- 【iOS】标签视图与分组静态表布局使用、利用通知和全局变量传值
- 关于后盾网yii框架的学习小结(2)--创建控制器,视图,布局等
- 4.IDA-导航(跳转到地址、导航按钮、栈帧、调用约定、局部变量布局、IDA的栈视图)
- 【安卓-自定义布局】安卓App开发思路 一步一个脚印(十四)实现Fragment的缓冲视图和数据,防止重复加载
- Android学习笔记(九) 视图的应用布局效果
- 一步步学习微软InfoPath2010和SP2010--第三章节--表单设计基础:处理InfoPath布局、控件和视图(7)--添加含规则的提交按钮到Flight Delay表单
- 混合使用XML布局文件和代码控制视图
- MVC4 Layouts布局视图--局部视图
- [IOS 视图布局]--分享样式REComposeViewController
- Yii 2.0 视图的深入解读
- iOS开发从入门到精通--手动布局子视图
- ios6到ios7视图的布局对绘图的影响及解决办法
- YII框架页面使用frameset布局(一)
- 使用通知机制,在dismissViewControllerAnimated后,completion传值给上一个父视图方法
- StoryBoard 视图切换和传值