I have an array of $items in Yii application which I want to paginate. The array is not related to the database so there's no condition to consider here, just a bunch of defined items that I need to display. So I'm trying to use the CActiveDataProvider like this:
$dataProvider = new CActiveDataProvider($items, array(
'pagination' => array(
'PageSize' => 10,
)
));
$this->renderPartial('view', array('dataProvider'=>$dataProvider));
Then in the view I'm trying to display the information:
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'template'=>"{items}\n{pager}",
));
I get a Call to a member function getDbCriteria() on a non-object
fatal error which is totally understandable since my $items array is customized and not database related so my question is how can I go around this issue and is it even possible using the CActiveDataProvider?
If it's not, is there another way to create a pagination for a custom non-database related array?
There is CArrayDataProvider for this case.
$dataProvider=new CArrayDataProvider($items, array(
'pagination'=>array(
'pageSize'=>10,
),
));