yii的layouts的使用
发布时间:2020-12-14 13:37:47 所属栏目:大数据 来源:网络整理
导读:yii的layouts的使用我们在控制器中使用render()时,yii会默认的载入布局。1.在protected/componets下的Controller.php中修改$layout变量,来指定自定义布局文件。例: $layout='//layouts/mylayout';2.在protected/views/layouts下创建mylayout.php布局文件
yii的layouts的使用
我们在控制器中使用render()时,yii会默认的载入布局。
1.在protected/componets下的Controller.php中修改$layout变量,
来指定自定义布局文件。
例: $layout='//layouts/mylayout';
2.在protected/views/layouts下创建mylayout.php布局文件。
3.在布局文件中加入你自已的代码,例:
xxxx header 公共头部样式 xxxx
<?php echo $content; ?>
xxxx footer 公共尾部样式 xxxx
4.在控制器$this->render();时你就会看到你的布局样式被渲染出来了。
? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |