Simple Pagination Algorithm using ColdFusion

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.



8 Thoughts

  1. Murtaza says:

    nice tutorial thanks

    ————————
    http://www.pakbridge.com

  2. Sacha says:

    Thanks for you support !
    When I have time I will redo this code snippet better, maybe using javascript or php instead of coldfusion, and providing illustrated examples along the way.

  3. Valtee says:

    Thanx for the code. Now i am starting to feel how nice coldfusion is.

  4. Valtee says:

    Have to revisit this once again. Just wondering where the 1st and last pages are coming from

  5. Sacha says:

    In this script, I assume the first page is simply “1”.

    The “last page” variable has to be defined before my code. Usually this variable will depend on outside factors, like your database’s content, or search results number, etc.

  6. Francesco says:

    Bad code, there are some variable that should be set before, and it needs some cfoutput…

    Good tutorial however…

  7. Sacha says:

    Feel free to post your solution. I haven’t done any coldfusion for the last year, so I kinda forgot the syntax..

  8. Iyhtamli says:

    Hold the line, please Kds Sex
    79120

Your Thoughts...


All content © Copyright 2017 by Sacha Greif.
Subscribe to RSS Feed – Posts or just Comments

Powered by WordPress
Designed by Graph Paper Press
Redesigned by Me