Feature Request #2541
Pagination: how to manually define page number
|Assignee:||Geert De Deckere||% Done:|
At this moment Pagination calculates page number with some Request params ('current_page' settings). But what if I want to set my own page number?
For example, I want to show last page. I dont know its number yet, and Request (for any reason) doesnt contain it. I suggest to add third param to 'current_page' array, let it be 'page' key. If it presents, Pagination should set $this->current_page = $this->config['current_page']['page'] or it will be calculated as current Pagination class does. In my opinion, 'source' and 'key' params by default should be used in routing only (Pagination's url() method).
#3 Updated by Geert De Deckere almost 5 years ago
Here's a patch with the solution you described: http://gist.github.com/357842
However, it would probably be cleaner to just use the
current_page setting for it, and then use
page_source_key to set the URL related page settings. You lose the rather ugly array setting. This change would not be backwards compatible, though. Your config would look like this:
array( 'current_page' => 31 // Optionally set the current page number manually 'page_source' => 'query_string', // Where is the current page number stored: query_string or route? 'page_source_key' => 'page', // The query_string key or the route param key )
Instead of (currently):
array( 'current_page' => array('source' => 'query_string', 'key' => 'page', 'page' => 31), )
Another alternative would be to something like this:
array( 'current_page' => 31 'page_source' => 'query_string: page', )
I can't make my mind up, can I?
#6 Updated by Geert De Deckere over 4 years ago
- Status changed from New to Closed
- Resolution set to fixed
I implemented the proposed patch.