Hi All,
I am having difficulty getting my CLinkPager to properly paginate my list. Instead of splitting my items into multiple pages it just puts them all onto one page. It seems to be able to tell how many pages it needs because it puts the right number of pages in the pager at the bottom but all the items end up on the first page.
My Controller Code:
...
$pins = $pinCollection->findAll();
$criteria = $pinCollection->getDbCriteria();
if($criteria){
error_log(json_encode($criteria));
}
$item_count = count($pins);
//$item_count = count(Pin::model()->count($criteria));
$pages = new CPagination($item_count);
$pages->setPageSize(20);
$pages->applyLimit($criteria); // the trick is here!
$this->render('list',array(
'pins' => $pins,
'item_count'=>$item_count,
'page_size'=>50,
'pages'=>$pages,
));
$pins is the whole list of items that I want to display
My View Code:
<?php if ($pins): ?>
<table id="pinsDataGrid">
<?php foreach ($pins as $_pin): ?>
<tr>
<td width="23">
<?php
echo CHtml::image(Yii::app()->baseUrl . '/images/arrow.png', 'Drag to a folder or category', array(
'class' => 'draglist',
'title' => 'Drag to a folder or category',
));
?>
ETC..........
</tr>
<?php endforeach; ?>
</table>
<?php
$this->widget('CLinkPager', array(
'currentPage'=>$pages->getCurrentPage(),
'itemCount'=>$item_count,
'pageSize'=>$page_size,
'maxButtonCount'=>5,
//'nextPageLabel'=>'My text >',
'header'=>'',
));
?>
<?php endif; ?>
Thanks in advance