From e01fd0fc3b694d12dc6b968727bd7f21f8c1a0fb Mon Sep 17 00:00:00 2001
From: Derek Allard
Date: Mon, 5 Jul 2010 11:06:07 -0400
Subject: suppress page list
---
system/libraries/Pagination.php | 37 ++++++++++++++++++++----------------
user_guide/changelog.html | 2 +-
user_guide/libraries/pagination.html | 9 +++++++++
3 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 68c35a57e..3a0632d09 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -56,6 +56,7 @@ class CI_Pagination {
var $num_tag_close = '';
var $page_query_string = FALSE;
var $query_string_segment = 'per_page';
+ var $display_pages = TRUE;
var $anchor_class = '';
/**
@@ -216,30 +217,34 @@ class CI_Pagination {
}
- // Write the digit links
- for ($loop = $start -1; $loop <= $end; $loop++)
+ // Render the pages
+ if ($this->display_pages !== FALSE)
{
- $i = ($loop * $this->per_page) - $this->per_page;
-
- if ($i >= 0)
+ // Write the digit links
+ for ($loop = $start -1; $loop <= $end; $loop++)
{
- if ($this->cur_page == $loop)
- {
- $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
- }
- else
+ $i = ($loop * $this->per_page) - $this->per_page;
+
+ if ($i >= 0)
{
- $n = ($i == 0) ? '' : $i;
-
- if ($n == '' && $this->first_url != '')
+ if ($this->cur_page == $loop)
{
- $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$loop.''.$this->num_tag_close;
+ $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page
}
else
{
- $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
+ $n = ($i == 0) ? '' : $i;
+
+ if ($n == '' && $this->first_url != '')
+ {
+ $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$loop.''.$this->num_tag_close;
+ }
+ else
+ {
+ $n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
- $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'">'.$loop.''.$this->num_tag_close;
+ $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'">'.$loop.''.$this->num_tag_close;
+ }
}
}
}
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 4f86c1e94..94eff05ba 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -79,7 +79,7 @@ Hg Tag:
Libraries
- Added $prefix, $suffix and $first_url properties to Pagination library.
- - Added the ability to suppress first, previous, next and last links by setting their values to FALSE in the Pagination library.
+ - Added the ability to suppress first, previous, next, last, and page links by setting their values to FALSE in the Pagination library.
- Added Security library, which now contains the xss_clean function, filename_security function and other security related functions.
- Added CSRF (Cross-site Reference Forgery) protection to the Security library.
- Added $parse_exec_vars property to Output library.
diff --git a/user_guide/libraries/pagination.html b/user_guide/libraries/pagination.html
index 33c871078..521b708b1 100644
--- a/user_guide/libraries/pagination.html
+++ b/user_guide/libraries/pagination.html
@@ -197,6 +197,15 @@ something different you can specify it.
$config['num_tag_close'] = '</div>';
The closing tag for the "digit" link.
+Hiding the Pages
+
+If you wanted to not list the specific pages (for example, you only want "next" and "previous" links), you can suppress their rendering by adding:
+
+
+$config['display_pages'] = FALSE;
+
+
+
Adding a class to every anchor
If you want to add a class attribute to every link rendered by the pagination class, you can set the config "anchor_class" equal to the classname you want.
--
cgit v1.2.3-24-g4f1b