Showing posts with label Pagination. Show all posts
Showing posts with label Pagination. Show all posts

Saturday, March 20, 2010

ReBuild Pagination for Controller on CodeIgniter

this function is using for easily using pagination library in one line.
just insert this function in your controller, and the other function call it:

/**
 * set paging for easy use :)
 * @access private
 * @param string $url
 * @param int $total
 * @param int $perpage
 * @param int $numlink
 * @return void
 */
function setPaging($url='', $total=0, $perpage=20, $numlink=3){
 if(!is_numeric($total)){
  $total=0;
 }
 if(!is_numeric($perpage)){
  $perpage=20;
 }
 if(!is_numeric($numlink)){
  $numlink=3;
 }
 $this->load->library('pagination');
 $segment=explode('/',$url);