cf_MagicPager: Updated.

I have updated cf_MagicPager See its previous entry. It now has 3 added parameters that allow CSS classes to be added to style the look of the output. Download sample code, and docs in a zip here.

View running example of the below source code here

<!---change the appearance (colours/fonts/etc) by modifying these styles. Or add your own. --->
<style type="text/css">
.numberlinkClass {color:#0080ff;font-family:courier;font-weight:normal;font-size:large;}
.currentPageNumberClass {color:#0000ff;font-family:courier;font-weight:normal;font-size:large;}
.nextPreviouslinkClass {color:#000000;font-family:impact;font-weight:normal;font-size:x-large;}
</style>

<cfoutput>
<!---creates a query with some test data. This process would be best done in a cfc but is shown
this way for easy demo purposes.

Your cfc should return a record set and the two variables needed by the the tag to function, in a
structure. i.e NumberOfLinksOnPage and numberOfPages --->
   

<!--- Create a new three-column query, specifying the column data types --->
<cfset myQuery = QueryNew("recordNumber", "Integer")>
<!--- Make two rows in the query --->
<cfset newRow = QueryAddRow(MyQuery, 307)>
<cfloop from="1" to="307" index="i">
<!--- Set the values of the cells in the query --->
<cfset temp = QuerySetCell(myQuery, "recordNumber", #i#, #i#)>
</cfloop>

<!---These are the only 2 values that the tag needs to run. --->
<cfset variables.numberOfRecordsOnPage = 10>
<cfset variables.numberOfPages = #myQuery.recordCount# / #variables.numberOfRecordsOnPage#>

      <!---This is ensures page number default to number 1 when first called --->
<cfparam name="url.pageNumber" default="1" type="numeric">
      <!---here using url.pagenumber to work out what records to display on current page --->
      <cfset variables.from = ((#url.pageNumber# * #variables.numberOfRecordsOnPage#) - #variables.numberOfRecordsOnPage#) + 1>
    <cfset variables.to = (#url.pageNumber# * #variables.numberOfRecordsOnPage#)>
</cfoutput>

<P><b>Running cfMagicPager. Browsing through 307 records.</b></P>
<cf_magicPager
NumberOfPages="#variables.numberOfPages#"
numberOfRecordsOnPage="#variables.numberOfRecordsOnPage#"
numberlinkClass="numberlinkClass"
nextPreviouslinkClass="nextPreviouslinkClass"
currentPageNumberClass="currentPageNumberClass">

</cf_magicPager>

<P>
<!---dislay your records here --->
<cfloop query = "myQuery" startrow="#variables.from#" endrow="#variables.to#">
<CFOUTPUT><div align="center">Record Number: <b>#recordNumber#</b></div></CFOUTPUT><br>
</cfloop>
</P>


<cf_magicPager NumberOfPages="#variables.numberOfPages#"
numberOfRecordsOnPage="#variables.numberOfRecordsOnPage#"
numberlinkClass="numberlinkClass"
nextPreviouslinkClass="nextPreviouslinkClass"
currentPageNumberClass="currentPageNumberClass">

</cf_magicPager>

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Elliott Kayne's Gravatar This is cool and I got it working, however, how can I show the pages like I see on most sites like this: << 1,2, 3 .... 30, 31, 33, 34 NEXT >>
What I want is the first 3 or 5 pages, the .... the last few pages?

Thanks for a very cool tag.
# Posted By Elliott Kayne | 3/23/09 11:29 PM
Paul's Gravatar Glad u like it!

Sorry no plans to do it as you ask. Just don't have the time. I modeled it on how Google lays out its links. Figured their way was best.
# Posted By Paul | 3/23/09 11:46 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.002. Contact Blog Owner