下面是yii框架后台modules控制层里面的一个控制器中的方法,最好是在编辑器里注释一下每行的意思。谢谢了 5
publicfunctionactionAdImages(){$this->adminMenu=self::getMenu();//print_r($this->admi...
public function actionAdImages()
{
$this->adminMenu = self::getMenu();
//print_r($this->adminMenu);exit;
$types = Lookup::model()->getListToOption(array('is_page'=>false,'type'=>'AdImages'), array('type'));
//print_r($types);exit;
$condition = array(
'is_page' => false,
);
$data = Adimages::getList($condition, array('type','status'));
if ($data['code']) {
$data = $data['data'];
} else {
throw new Exception($data['data'], 1);
}
if (!empty($data)) {
$data = $this->replacetype($data, $types);
}
$repdp = new CArrayDataProvider($data, array(
'id'=>'report',
'pagination'=>array(
'pageSize'=>10,
),
));
$this->render('adimages', array(
'data'=>$repdp,
));
} 展开
{
$this->adminMenu = self::getMenu();
//print_r($this->adminMenu);exit;
$types = Lookup::model()->getListToOption(array('is_page'=>false,'type'=>'AdImages'), array('type'));
//print_r($types);exit;
$condition = array(
'is_page' => false,
);
$data = Adimages::getList($condition, array('type','status'));
if ($data['code']) {
$data = $data['data'];
} else {
throw new Exception($data['data'], 1);
}
if (!empty($data)) {
$data = $this->replacetype($data, $types);
}
$repdp = new CArrayDataProvider($data, array(
'id'=>'report',
'pagination'=>array(
'pageSize'=>10,
),
));
$this->render('adimages', array(
'data'=>$repdp,
));
} 展开
1个回答
展开全部
public function actionAdImages()//控制器方法
{
$this->adminMenu = self::getMenu();//调用当前类的静态方法getMenu
//print_r($this->adminMenu);exit;
$types = Lookup::model()->getListToOption(array('is_page'=>false,'type'=>'AdImages'), array('type'));//调用Lookup模型的getListToOption方法
//print_r($types);exit;
$condition = array(//定义一个数组
'is_page' => false,
);
$data = Adimages::getList($condition, array('type','status'));//调用Adimages类的getList静态方法
if ($data['code']) {//返回的data存在code元素
$data = $data['data'];//赋值
} else {//没有就抛出一个异常
throw new Exception($data['data'], 1);
}
if (!empty($data)) {//data不为空
$data = $this->replacetype($data, $types);//执行当前对象的replacetype方法
}
$repdp = new CArrayDataProvider($data, array( //实例化一个CArrayDataProvider对象
'id'=>'report',//对象ID
'pagination'=>array( //实现分页
'pageSize'=>10, //每页显示10行
),
));
$this->render('adimages', array(//将data渲染到adimages视图
'data'=>$repdp,
));
}
//只能这么说了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询