Feature Request #2541

Pagination: how to manually define page number

Added by Ivan Brotkin over 3 years ago. Updated almost 3 years ago.

Status:Closed Start date:02/04/2010
Priority:Normal Due date:
Assignee:Geert De Deckere % Done:

0%

Category:Modules:Pagination
Target version:v3.0.7
Resolution:fixed Points:

Description

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).

History

Updated by Woody Gilk about 3 years ago

  • Target version set to v3.0.4

Updated by Woody Gilk about 3 years ago

  • Target version changed from v3.0.4 to v3.0.5

Updated by Geert De Deckere about 3 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 and 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?

Updated by Woody Gilk almost 3 years ago

  • Target version changed from v3.0.5 to v3.0.6

Updated by Woody Gilk almost 3 years ago

  • Target version changed from v3.0.6 to v3.0.7

Updated by Geert De Deckere almost 3 years ago

  • Status changed from New to Closed
  • Resolution set to fixed

Also available in: Atom PDF