Simple Pagination Algorithm using ColdFusion

November 19 2007 , 37 comments

For one of my projects, I needed a simple pagination module. The requirements were pretty standard:

  • The first and last page should always be displayed
  • There should always be the same number of pages displayed for consistency (+- 1)
  • There should be maximum code reuse
  • It should be easily configurable
  • The current page should stand out

So here is my answer to this problem. Even if you’re not familiar with coldfusion, you should be able to understand the code. (just mentally replace <cfif> by “if”,<cfloop> by “for”, etc.)
[cfm]

























1

1

#beforeSeparator#



#i#

#i#


#afterSeparator#


#lastPage#

#lastPage#

[/cfm]

P.S.: if you find your life boring and lacking adventure, try getting ColdFusion code to display right in WordPress. I promise it will get your adrenaline levels up in no time.