CodeIgniter Pagination Class – Url with get parameter

let say you have paging for search content like this

http://myd0m41n.net/search/result

search is controllers, result is function

and you want to pass parameter $_GET to ur, so the result will see like this

http://myd0m41n.net/search/result?param1=someval&param2=1&param3=false

the problem you need paging to make your (download) data client smaller

the solution you can modify the search function to accept parameter page, and set ‘suffix’ pagination configĀ  value


class search extend CI_Controllers {

...

function result ( $page = 0) {

// your result here

$this->load->library('pagination');

$cfg = array(

'base_url'=>base_url().'search/result',

'use_page_numbers'=>TRUE,

'uri_segment' => 3,

'per_page'=> 20,

'total_rows' => 100,

'suffix' => '?' . http_build_query($_GET, '', "&")

);

$this->pagination->initialize($cfg);

echo $this->pagination->create_links();

}

...

}

and the result will look like this

ci-pagination-get-param

Published by

G3n1k

just to remember what i had known :)

2 thoughts on “CodeIgniter Pagination Class – Url with get parameter”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s