Use this in your _view.php instead of whatever you are doing:
<?= CHtml::encode($data['subject']); ?>
If it still fails, check to see if the $dataProvider
actually has records:
<?php var_dump($dataProvider->data); ?>
I have a problem with CArrayDataProvider apparently returning empty value. When I type the SQL (see below), on mysql, I get 7 records, my view displays 7 lines but with empty values.
Here is the necessary code, if you need more, please ask me.
actionIndex of the Post Controller
$connection=Yii::app()->db;
$user_id = Yii::app()->user->id;
$sql = 'SELECT * FROM post
LEFT JOIN comment ON post.id = comment.post_id
AND comment.user_id =:user_id
LIMIT 0 , 30 ';
$command=$connection->createCommand($sql);
$command->bindParam(':user_id', $user_id,PDO::PARAM_STR);
$rawData = $command->queryAll();
$dataProvider=new CArrayDataProvider($rawData, array(
'id'=>'post',
'sort'=>array(
'defaultOrder' => 'post.created',
),
'pagination'=>array(
'pageSize'=>10,
),
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
'category_id'=>$category_id,
));
}
view Index
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
)); ?>
and view _view
<?php echo CHtml::encode(Post::model()->subject); ?>
Is anyone can see where the problem comes from?
Thank you in advance for your help.