我想显示评论数据,但我有一个错误:
" Property" CListView.dataprovider"没有定义。"我的代码有什么问题?我有谷歌搜索,但仍然得到该通知显示的原因。
这是我的控制器功能:
public function actionView($id,$c)
{
$modelviewedtopic=$this->loadModel($id,$c);
if($modelviewedtopic){
$modelviewedtopic->viewed=$modelviewedtopic->viewed+1;
$modelviewedtopic->save();
}
$modelforumcoment=new ForumComment;
$criteria = new CDbCriteria();
$criteria->condition = 'id_forum_topic=:id_forum_topic';
$criteria->params = array(':id_forum_topic'=>$id);
$dataprovider=new CActiveDataProvider('ForumComment',array(
'criteria'=>$criteria,
'sort'=>array(
'defaultOrder'=>'update_date ASC',
),
));
$this->render('view',array(
'model'=>$this->loadModel($id,$c),
'modelforumcoment'=>$modelforumcoment,
'dataprovider'=>$dataprovider,
));
}
这是我的观点:
$comment = ForumComment::model()->findAllByAttributes(array('id_forum_topic'=>$model->id_forum_topic,'userid'=>Yii::app()->user->id));
$total_comment = count($comment);
$widget = $this->widget('zii.widgets.CListView',array(
'id'=>'commentlist',
'loadingCssClass'=>'',
'afterAjaxUpdate'=> 'reloadeditable',
'dataprovider'=>$dataprovider,
'enableHistory' => true,
'emptyText'=>'<b>No Comments</b>',
'summaryText'=>'',
'itemView'=>'_view_comment',
));
Editable::attachAjaxUpdateEvent($widget);
Yii::app()->clientScript->registerScript('reloadeditable', "
function reloadeditable(id, data) {
if('$total_comment' == 0){
location.reload();
}
}
");
我的代码有什么问题?
提前感谢:)
答案 0 :(得分:0)
'dataprovider'=>$dataprovider
你必须改为
'dataProvider'=>$dataprovider
因为变量名称区分大小写