Welcome Guest, Not a member yet? Register   Sign In
Question about pagination on CI3
#1

I am a little lost with CI3 pagination.

Let say I have
Code:
http://example.com/test/page/1/category/item_id

using the 3rd segment as the page number (page 1, page 2, page 3, ...)

$config['uri_segment'] = 3;

I know the documentation says how to reuse the query string like this
Code:
http://example.com/index.php?c=test&m=page&per_page=20
 
But that is not working for me. So my question is how do I pass the /category/item_id segments or additional segments on the pagination numbers?

all I got so far is

Code:
1 = http://example.com/test/page/1
2 = http://example.com/test/page/2
3 = http://example.com/test/page/3

and no /category/item_id segments after the page number

Thank You!
Reply
#2

Segments = Controller / Method / Method / etc;

PHP Code:
$config['uri_segment'] = 5
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(05-17-2015, 03:02 AM)InsiteFX Wrote: Segments = Controller / Method / Method / etc;




PHP Code:
$config['uri_segment'] = 5

That will put me in a hard spot due to different variables I must pass on different controllers.

I manage to find a walk around using pagination's $config['suffix'] like this

Code:
$additional_variables = '/category/item_id';

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

$config['base_url'] = base_url().'test/page/';
$config["uri_segment"] = '3';
$config['total_rows'] = 200;
$config['per_page'] = 10;

$config['suffix'] = $additional_variables.$this->config->item('url_suffix');

$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config);

so now I can switch from

Code:
http://example.com/test/page/1

to

Code:
http://example.com/test/page/1/category/item_id

everything seems to be working right now but not with page number 1. CI pagination ignore everything after the second segment on page 1 like this

Code:
1 = http://example.com/test/page/1
2 = http://example.com/test/page/2/category/item_id
3 = http://example.com/test/page/3/category/item_id
4 = http://example.com/test/page/4/category/item_id

that means the user can't go back to see items on the requested category on page 1
Reply
#4

(This post was last modified: 05-17-2015, 08:28 AM by Mel9pr.)

(05-17-2015, 08:08 AM)Mel9pr Wrote: everything seems to be working right now but not with page number 1. CI pagination ignore everything after the second segment on page 1 like this



Code:
1 = http://example.com/test/page/1
2 = http://example.com/test/page/2/category/item_id
3 = http://example.com/test/page/3/category/item_id
4 = http://example.com/test/page/4/category/item_id

that means the user can't go back to see items on the requested category on page 1

Correction: page number 1 can be set using

Code:
$config['first_url'] = base_url().'test/page/1'.$addittional_variables.$this->config->item('url_suffix');

so now I can have

Code:
http://example.com/test/page/1/category/item_id
Reply




Theme © iAndrew 2016 - Forum software by © MyBB