More information about this topic
Reset database
 | 
Sample data
Page 2
  • 6
  • 7
  • 8
  • 9
  • 10

protected/modules/UiModule/views/pagination/basic_pager.php

<b>Page <?php echo $pages->getCurrentPage()+1; ?></b>
<ul><li><?php echo implode('</li><li>', $sample); ?></li></ul>

protected/modules/UiModule/controllers/PaginationController.php

	public function actionBasicPager() {

		$item_count =32;
		$page_size =5;

		$pages =new CPagination($item_count);
		$pages->setPageSize($page_size);

		// simulate the effect of LIMIT in a sql query
		$end =($pages->offset+$pages->limit <= $item_count ? $pages->offset+$pages->limit : $item_count);

		$sample =range($pages->offset+1, $end);

		$this->render('basic_pager', array(
			'item_count'=>$item_count,
			'page_size'=>$page_size,
			'items_count'=>$item_count,
			'pages'=>$pages,
			'sample'=>$sample,
		));
	}
CPagination
Go to page: Go to page:

protected/modules/UiModule/views/pagination/basic_pager.php

$this->widget('CLinkPager', array(
	'pages'=>$pages,
));

$this->widget('CListPager', array(
	'pages'=>$pages,
));
CLinkPager

protected/modules/UiModule/views/pagination/basic_pager.php

$this->widget('CLinkPager', array(
	'currentPage'=>$pages->getCurrentPage(),
	'itemCount'=>$item_count,
	'pageSize'=>$page_size,
	'maxButtonCount'=>6,
	'nextPageLabel'=>'My text &gt;',
	'header'=>'',
));
CListPager
My Text:

protected/modules/UiModule/views/pagination/basic_pager.php

$this->widget('CListPager', array(
	'currentPage'=>$pages->getCurrentPage(),
	'itemCount'=>$item_count,
	'pageSize'=>$page_size,
	'header'=>'My Text: ',
));
Fork me on GitHub