Hello all,
I am having a problem with my clistview. It is only returning 4 results on the first page and 10 on all the rest.
If i set the value it increases on the first page however it doesn’t show the right number on the first page.
i.e. if i set it to 20 it shows 14 on the first page and 20 on all the rest. It also makes my queries go from 7 to 18.
If I add $critera->order = ‘…’, it works right but increases my queries from 7 to 13
Anyone know why it’s doing this and how i can fix it?
Current code:
<?php
$current_user = Yii::app()->user->id;
$criteria = new CDbCriteria();
$criteria->together = TRUE;
$criteria->with = array(
'creator0', 'updater0', 'addonphotos');
$criteria->condition = 't.status=:status';
$criteria->params = array(':status' => 1);
$criteria->order = 'create_date DESC';//If I don't have this portion it doesn't work
$dataProvider = new CActiveDataProvider(Addon::model(), array('criteria'=>$criteria,
));
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'id'=>'addonListView',
'pager'=> array(
'header' => '',
'footer' => '',
'firstPageLabel' => 'First Page',
'prevPageLabel' => 'Prev. Page',
'nextPageLabel' => 'Next Page',
'lastPageLabel' => 'Last Page',
),
'template'=>'{sorter}{items}{pager}',
'emptyText'=>'We did not find any items with your search critera. Please try another search.',
'sortableAttributes'=>array(
'name',
'price',
'create_date',
'update_date'
),
)); ?>