Skip to content

Commit

Permalink
Added anchor_class and show_count options.
Browse files Browse the repository at this point in the history
Added anchor_class option to allow a CSS class to be assigned to the
links in the pager.

Added show_count option to allow hiding of the "Showing 10 to 20 of 100
text on the pager.
  • Loading branch information
Dillie-O committed Feb 16, 2012
1 parent 97a7db2 commit 64bd371
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 11 deletions.
34 changes: 23 additions & 11 deletions Jquery_pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class Jquery_pagination{
var $div = '';
var $postVar = '';
var $additional_param = '';

// Added by Sean
var $anchor_class = '';
var $show_count = true;

/**
* Constructor
Expand Down Expand Up @@ -94,6 +98,12 @@ function initialize($params = array())
}
}
}

// Apply class tag using anchor_class variable, if set.
if ($this->anchor_class != '')
{
$this->anchor_class = 'class="' . $this->anchor_class . '" ';
}
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -165,20 +175,21 @@ function create_links()
// And here we go...
$output = '';

// SHOWING LINKS
// SHOWING LINKS
if ($this->show_count)
{
$curr_offset = $CI->uri->segment($this->uri_segment);
$info = 'Showing ' . ( $curr_offset + 1 ) . ' to ' ;

$curr_offset = $CI->uri->segment($this->uri_segment);
$info = 'Showing ' . ( $curr_offset + 1 ) . ' to ' ;

if( ( $curr_offset + $this->per_page ) < ( $this->total_rows -1 ) )
if( ( $curr_offset + $this->per_page ) < ( $this->total_rows -1 ) )
$info .= $curr_offset + $this->per_page;
else
else
$info .= $this->total_rows;

$info .= ' of ' . $this->total_rows . ' | ';

$output .= $info;
$info .= ' of ' . $this->total_rows . ' | ';

$output .= $info;
}

// Render the "First" link
if ($this->cur_page > $this->num_links)
Expand Down Expand Up @@ -247,12 +258,13 @@ function create_links()
function getAJAXlink( $count, $text) {

if( $this->div == '')
return '<a href="'. $this->base_url . $count . '">'. $text .'</a>';
return '<a href="'. $this->anchor_class . ' ' . $this->base_url . $count . '">'. $text .'</a>';

if( $this->additional_param == '' )
$this->additional_param = "{'t' : 't'}";

return "<a href=\"#\"
return "<a href=\"#\"
" . $this->anchor_class . "
onclick=\"$.post('". $this->base_url . $count ."', ". $this->additional_param .", function(data){
$('". $this->div . "').html(data);" . $this->js_rebind ."; }); return false;\">"
. $text .'</a>';
Expand Down
33 changes: 33 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
Greetings!

My name is Sean Patterson, and after using this VERY helpful jQuery Pagination
library for CodeIgniter, I wound up adding a couple updates that I thought would
be helpful for the project.

1. The anchor_class variable has been added to this library, to mirror what is
available in the original CodeIgniter pagination library. If you need to
assign a CSS class to all of the links in your pager, simply set the
anchor_class variable in your initialization:

$ajax_pagination_config['anchor_class'] = 'page_link';

This will apply the appropriate class to every anchor tag.

2. I've added a variable to optionally hide the "Showing 10 to 20 of 100" text
that shows up in the pager. I needed this text hidden for my pagers, and
initially I commented out the code entirely, but thought it would be much
nicer to add that as an option. To enable/disable the "count" text, use the
following variable in your initialization:

$ajax_pagination_config['show_count'] = false;

By default this value is set to true if you do not configure it.

I hope this helps folks out there. CodeIgniter is a great tool and the AJAX
pagination provided by jQuery in this code has helped me even more!

[:: Sean ::]
[:: http://about.me/dillieo ::]

*** Original README ***

Hi My name is Amzad Hossain Tohin
Blog: tohin.wordpress.com

Expand Down

0 comments on commit 64bd371

Please sign in to comment.