Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter pagination first page URL

I know their are a few questions on codeigniter pagination but from what I can tell they dont seem to be relevent.

FYI I am using page numbers in my URL, not the index (using config option use_page_numbers)

So my problem is the first link.

My url structure for a page other than page 1 is:

http://www.something.com/foo/page/x

That all works fine however when I hover over the link for page 1 the url that comes up is:

http://www.something.com/foo/page/

Now i know thats because ive declared the base url as:

$config['base_url'] = $this->uri->slash_segment(1, 'both') . 'page/';

But is it possbile to either have the URl for page 1 as:

http://www.something.com/foo/

OR

http://www.something.com/foo/page/1/

Hope that makes sense and someone can help out. I did try setting the base_url to page/1 if the 3rd segment was empty but no joy.

thanks for reading

like image 425
fl3x7 Avatar asked Mar 24 '26 22:03

fl3x7


1 Answers

Imagine your base_url is :

$config['base_url'] = base_url() . 'method/page/';

So, change the code like below to have the first URL as you wish :

$config['base_url'] = base_url() . 'method/page/';
$config['first_url'] = '1';
$this->pagination->initialize($config);

Now the first page link should be:

http://example.com/method/page/1

like image 160
Afshin Avatar answered Mar 26 '26 12:03

Afshin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!