在Yii框架的frontpage上创建数据块
我是Yii框架的新手。我想在网站首页的框中显示一些用户控制器输出。但我不知道怎么做。你能给我一个做这件事的计划吗?方法一: 在主页“视图”中,添加类似代码在Yii框架的frontpage上创建数据块,yii,Yii,我是Yii框架的新手。我想在网站首页的框中显示一些用户控制器输出。但我不知道怎么做。你能给我一个做这件事的计划吗?方法一: 在主页“视图”中,添加类似代码 <div id="box-id"> <?php if( Yii::app()->user->isGuest() ) { // handle guest } else { $this->renderPar
<div id="box-id">
<?php
if( Yii::app()->user->isGuest() ) {
// handle guest
}
else {
$this->renderPartial('/user/homebox', array() );
}
?>
</div>
在UserController中。。定义一些动作“homebox”
function actionHomebox() {
if( Yii::app()->user->isGuest() ) {
// handle guest
}
else {
$this->renderPartial('homebox', array() );
}
}
您必须在视图(views/user/)文件夹中的某个位置定义视图“homebox”
function actionHomebox() {
if( Yii::app()->user->isGuest() ) {
// handle guest
}
else {
$this->renderPartial('homebox', array() );
}
}