summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-05-21 07:04:26 +0200
committerDerek Allard <derek.allard@ellislab.com>2008-05-21 07:04:26 +0200
commitc6238e983455ba4ab08ad9bf4d6d5d7f75d8c10c (patch)
treee8290923e25db040f3f9e0ab440d65e4fb252c2e
parent8ddc0db3bb835fbb880c25882b1016747527742c (diff)
customizable query string
-rw-r--r--system/libraries/Pagination.php27
-rw-r--r--user_guide/libraries/pagination.html2
2 files changed, 22 insertions, 7 deletions
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 2b8d3e454..000af10d2 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -51,6 +51,7 @@ class CI_Pagination {
var $num_tag_open = '&nbsp;';
var $num_tag_close = '';
var $page_query_string = FALSE;
+ var $query_string_segment = 'per_page';
/**
* Constructor
@@ -118,12 +119,26 @@ class CI_Pagination {
// Determine the current page number.
$CI =& get_instance();
- if ($CI->uri->segment($this->uri_segment) != 0)
+
+ if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
- $this->cur_page = $CI->uri->segment($this->uri_segment);
-
- // Prep the current page - no funny business!
- $this->cur_page = (int) $this->cur_page;
+ if ($CI->input->get($this->query_string_segment) != 0)
+ {
+ $this->cur_page = $CI->input->get($this->query_string_segment);
+
+ // Prep the current page - no funny business!
+ $this->cur_page = (int) $this->cur_page;
+ }
+ }
+ else
+ {
+ if ($CI->uri->segment($this->uri_segment) != 0)
+ {
+ $this->cur_page = $CI->uri->segment($this->uri_segment);
+
+ // Prep the current page - no funny business!
+ $this->cur_page = (int) $this->cur_page;
+ }
}
$this->num_links = (int)$this->num_links;
@@ -157,7 +172,7 @@ class CI_Pagination {
// string. If post, add a trailing slash to the base URL if needed
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
- $this->base_url = rtrim($this->base_url).AMP.'per_page=';
+ $this->base_url = rtrim($this->base_url).AMP.$this->query_string_segment.'=';
}
else
{
diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html
index d96f2d00c..d91a73eea 100644
--- a/user_guide/libraries/pagination.html
+++ b/user_guide/libraries/pagination.html
@@ -124,7 +124,7 @@ something different you can specify it.</p>
<p><code>http://www.your-site.com/index.php/test/page/20</code></p>
<p>If you have $config['enable_query_strings'] set to TRUE your links will automatically be re-written using Query Strings. This option can also be explictly set. Using $config['page_query_string'] set to TRUE, the pagination link will become.</p>
<p><code>http://www.your-site.com/index.php?c=test&amp;m=page&amp;per_page=20</code></p>
-<p>Note that &quot;per_page&quot; is the string automatically passed.</p>
+<p>Note that &quot;per_page&quot; is the default query string passed, however can be configured using $config['query_string_segment'] = 'your_string'</p>
<h2>Adding Enclosing Markup</h2>
<p>If you would like to surround the entire pagination with some markup you can do it with these two prefs:</p>