codeigniter pagination first page URL

11,009

Solution 1

I just ended up having the URL with the /foo/ without the 'page' segment in there. This was done using the normal method from the docs:

http://codeigniter.com/user_guide/libraries/pagination.html

Thanks to everyone for your input though.

Solution 2

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

Solution 3

This thing happens because you are adding 'page/' parameter to pagination base url

Just change your configuration for pagination. Set it as below:

$pagination['base'] = $this->config->item('base_url');
$config['base_url'] = $pagination['base'].'foo';

This works and the pagination link for the first page will be http://www.something.com/foo/

Share:
11,009
fl3x7
Author by

fl3x7

Updated on June 04, 2022

Comments

  • fl3x7
    fl3x7 almost 2 years

    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