From 8ddc0db3bb835fbb880c25882b1016747527742c Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Wed, 21 May 2008 04:54:39 +0000
Subject: Added support for query strings to the Pagination class,
automatically detected or explicitly declared.
---
system/libraries/Pagination.php | 13 +++++++++++--
user_guide/changelog.html | 1 +
user_guide/libraries/pagination.html | 11 ++++++++---
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 10af3fd11..2b8d3e454 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -50,6 +50,7 @@ class CI_Pagination {
var $prev_tag_close = '';
var $num_tag_open = ' ';
var $num_tag_close = '';
+ var $page_query_string = FALSE;
/**
* Constructor
@@ -152,8 +153,16 @@ class CI_Pagination {
$start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
$end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
- // Add a trailing slash to the base URL if needed
- $this->base_url = rtrim($this->base_url, '/') .'/';
+ // Is pagination being used over GET or POST? If get, add a per_page query
+ // 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=';
+ }
+ else
+ {
+ $this->base_url = rtrim($this->base_url, '/') .'/';
+ }
// And here we go...
$output = '';
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 1c1d7a3c5..568b3b961 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -69,6 +69,7 @@ SVN Revision: not currently released
Libraries
- Set the mime type check in the Upload class to reference the global mimes variable.
+ - Added support for query strings to the Pagination class, automatically detected or explicitly declared.
Other changes
diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html
index 5f9d8a0f1..d96f2d00c 100644
--- a/user_guide/libraries/pagination.html
+++ b/user_guide/libraries/pagination.html
@@ -117,9 +117,14 @@ something different you can specify it.
$config['num_links'] = 2;
-The number of "digit" links you would like before and after the selected page number. For example, the number 2
-will place two digits on either side, as in the example links at the very top of this page.
-
+The number of "digit" links you would like before and after the selected page number. For example, the number 2
+ will place two digits on either side, as in the example links at the very top of this page.
+$config['page_query_string'] = TRUE
+By default, the pagination library assume you are using URI Segments, and constructs your links something like
+http://www.your-site.com/index.php/test/page/20
+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.
+http://www.your-site.com/index.php?c=test&m=page&per_page=20
+Note that "per_page" is the string automatically passed.
Adding Enclosing Markup
If you would like to surround the entire pagination with some markup you can do it with these two prefs:
--
cgit v1.2.3-24-g4f1b