Welcome Guest, Not a member yet? Register   Sign In
Generic Pagination Class
#1

[eluser]theprodigy[/eluser]
I've written a generic paginate class. It can be used as a CI custom Library or in non-CI applications (as it does not contain any CI specific functionality)

It functions very similarly to CI's paginate class with one main difference.

I didn't like the fact with CI's pagination class that if you had 10 pages and set the number of links to 2 (2 before and 2 after), but were on page 1, it only showed 3 links, and if you were on page 2, it would show 4 links, and from then on out to page 8, it would show the 5 links you requested. Then it would go back to 4 links on page 9, and 3 links on page 10 ( it through my php ocd into overdrive, lol ).

My class asks for the number of pages you want shown, not the number of links before/after.

My class allows you to set things via a generic config function (with an assoc array as a parameter), or individual setter methods (each method has it's own set of parameters, see documented code for specifics).

The things you can set are:
Code:
$first_link_text;
$last_link_text;
$previous_link_text;
$next_link_text;
$replacement_text;
$pagination_href;
$total_items;
$items_per_page;
$current_page;
$number_of_pages;
$first_link_wrap_tags;
$last_link_wrap_tags;
$previous_link_wrap_tags;
$next_link_wrap_tags;
$numeric_link_wrap_tags;
$current_page_wrap_tags;

All items have default values, so you can choose to only set a few or all.

Also, this pagination class takes page numbers not record offset numbers.

What is returned is an array:
Code:
array(
     first => entire anchor tag for the first link
     last  => entire anchor tag for the last link
     prev  => entire anchor tag for the previous link
     next  => entire anchor tag for the next link
     pages => string containing multiple anchor tags for the individual pages, and the current page non-link.
     )

The code, I believe, is very well documented. I tried having a couple people alpha test it, but I have yet to hear any response.

You can download it here: Paginate Class

Please let me know what you think of this class, whether good or bad. I would love to hear your input.


Messages In This Thread
Generic Pagination Class - by El Forum - 04-12-2010, 07:19 PM
Generic Pagination Class - by El Forum - 04-14-2010, 06:15 AM
Generic Pagination Class - by El Forum - 04-27-2010, 03:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB