Hi I am new to Yii and what i am trying to do is i have hotels and its items and i want to display top rated. so in siteController
I get the data very well. but I tried to get multiple dataproviders and render index
page but it does not recognises the changed dataprovider name.
for ex
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$dataProviderHotel=new CActiveDataProvider('Hotel',array(
'criteria'=>array(
'condition'=>'hotel_rating > 8',
),
'pagination'=>array(
'pageSize'=>20,
),
));
$dataProviderItems = new CActiveDataProvider('Item',array(
'criteria'=>array(
'condition'=>'hotel_rating > 8',
),
'pagination'=>array(
'pageSize'=>20,
),
));
$this->render('index',array(
'dataProvider'=>array($dataProviderHotel,$dataProviderItem),
));
}
and in view exception is thrown that dataProviderHotel undefined view code is
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProviderHotel,
'summaryText'=>'',
'itemView'=>'_topHotels',
)); ?>