Welcome Guest, Not a member yet? Register   Sign In
Advanced pagination
#1

[eluser]Unknown[/eluser]
Hi,

I have the following URL for pagination:

http://127.0.0.1:10088/MyApp/index.php/a...10/id/DESC

1.) 10 = offset
2.) 10 = limit
3.) id = order_by
4.) DESC = direction

So when my controller ignites the model's query; it'll be like this:

Code:
SELECT * FROM `myBrands` ORDER BY `id` DESC LIMIT 10, 10

My pagination limits me now with these multiple segments (method parameters). These are my settings:

Code:
$tconfig['base_url'] = base_url().'index.php/admin/brands/';
$tconfig['uri_segment'] = 3;
$tconfig['total_rows'] = '99999';
$tconfig['per_page'] = $result_limit;

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

I had a problem before with shifting the uri_segment (the pagination wasn't tracked right..) so I stayed with the first segement in my controller.

This is how I link with sorting and stuff:
Code:
$tconfig['base_url'] = base_url().'index.php/admin/brands/'.$result_offset.'/'.$result_limit.'/'.$order_by.'/'.$direction.'/';

The offset variable is the one that causes pagination to work. Can I just do this?:
Code:
$tconfig['base_url'] = base_url().'index.php/admin/brands/'.$PAGINATION_MAGIC_KEY??.'/'.$result_limit.'/'.$order_by.'/'.$direction.'/';
#2

[eluser]Jamie Rumbelow[/eluser]
The $config['base_url'] declaration is only for the BASE url - in your view when you display this the offset will be tacked onto the end automatically. Then you can just append your other parameters to the URL string when you output it. As far as CodeIgniter's concerned - there is only one segment of the URL it needs to touch.

Jamie




Theme © iAndrew 2016 - Forum software by © MyBB