Welcome Guest, Not a member yet? Register   Sign In
Bug in Pagination Library?
#1

[eluser]fireproofsocks[/eluser]
Here's the scenario:

1. User searches, gets 18 results, 10 per page.
2. User goes to page 2 (showing results 11-18)
3. User selects to view 25 results per page (which still ends up showing results 11-18 because the offset doesn't change)
4. POOF! The links to page one disappear.

Is this a bug? Here's the code I'm using to generate the links (in a custom library):

Code:
function get_links()
{
        $config['base_url'] = $this->pagination_friendly_current_page();
        $config['total_rows'] = $this->get_count();
        $config['per_page'] = $this->get_limit();
        $this->CI->pagination->initialize($config);
        return $this->CI->pagination->create_links();
}

I'm pointing to several other functions here, but hopefully you can get the idea.
I tried passing the $config['cur_page'], but that didn't seem to have any effect. Seems to me that the pagination library needs to have an input for offset. How else does it know which page it's on?

Any ideas?
#2

[eluser]skunkbad[/eluser]
The pagination library needs some other things too, so stand in line!
#3

[eluser]Colin Williams[/eluser]
Quote:Seems to me that the pagination library needs to have an input for offset. How else does it know which page it’s on?

It uses the URI segment you have configured.

Quote:$config['uri_segment'] = 3;
The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it.

And there is no cur_page config setting. Not sure why you tried that.
#4

[eluser]fireproofsocks[/eluser]
Thanks for the input. I'm not using url segments for this; I've hacked CI to allow for certain GET parameters (heavily filtered) so that users can bookmark search results (the exact specification for the project was extensive). Perhaps the missing url segment is what's causing this particular error to surface; CI isn't finding it in the normal place, so I probably need to extend the Pagination class to accommodate for my GET array hacks.

Without looking thoroughly at the code in the system/library/pagination.php I saw a variable for $cur_page, so I thought it might be accessible as a config setting. The documentation doesn't specify what all the configuration options are: "Although there are some twenty items you can configure, at minimum you need the three shown". Since this left me guessing as to what those "20-some" options are, I thought I would take a guess and try $cur_page.

I don't know what other things are missing with the library or how long the line is, but finishing the documentation on this library would be a good place to start.
#5

[eluser]Colin Williams[/eluser]
Really? You didn't see the other 18 config options in the docs? Try scrolling down. They're all there. The class already works with query strings. I don't think you read all the docs, just the first heading




Theme © iAndrew 2016 - Forum software by © MyBB