Free code: Pagination.cfc
posted under category: Free Code For You on October 10, 2007 by Nathan
Last weekend I updated my family photos area. I have to do something to it every few months so my wife will keep using it.
In the process, I created a cfc for paging through a query. I saw something similar on cflib.org, but I was hoping for something a little more OO and a little more customizable for me to use on any number of other projects.
Some cool things about it is the customizable output and the caching when you call getRenderedHTML() so you can output it at the top and the bottom of the page without any performance hit.
Some room for improvement would be adding a few more convenience methods like getCurrentPageNumber() and the option to leave the <Previous link text up (but no link) when there is no previous page, that kind of thing. More suggestions are definitely welcome. Also I think the API will change somewhat to make it more discoverable, but I'm not sure how, yet.
I created it and licensed it this weekend without a release, then earlier this week, I realized I could use it in a project at work. I downloaded it and dropped it in, and it worked perfectly with nothing to change.
So, this is version 0.1 with a BSD license (free to do what you want with it but leave my © on it). Download Pagination.cfc here.
BTW, before there is any confusion, this is a one-use-only object, you create an instance of it when you need to output pagination and throw it away with the page. Do not put it in your application scope. Coldspring users, singleton=false.