•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 426,020 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,672 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser: Programming Forums
Views: 1047 | Replies: 8 | Solved
![]() |
Here goes. There's a lot here, so bear with me. This is actually two custom tags. One to set the variables and one to create the links.
Here is the first custom tag:
Now for the navigation links:
So, how do you use it? Like this:
Let me know how that works for you...
Here is the first custom tag:
ColdFusion Syntax (Toggle Plain Text)
<!--- pageNumSetup.cfm ---> <cfscript> // round page number variable up function roundPageNum(number) { var x = 0; x = Int(number); if(number - x neq 0) { x = x + 1; } return x; } </cfscript> <!--- Set Default values ---> <cfparam name="Caller.startRow" default="1"> <cfparam name="Caller.nextPage" default=""> <cfparam name="Caller.prevPage" default=""> <cfparam name="Caller.numPerPage" default="20"> <cfparam name="Caller.numPages" default="0"> <cfparam name="Caller.curPage" default="1"> <cfparam name="Attributes.queryName" default=""> <!--- Set values for previous and next pages ---> <cfset Caller.nextPage = Caller.startRow + Caller.numPerPage> <cfset Caller.prevPage = Caller.startRow - Caller.numPerPage> <!--- Determine the total number of pages for this search ---> <cfset Caller.numPages = Attributes.queryName.RecordCount / Caller.numPerPage > <cfset Caller.numPages = roundPageNum(Caller.numPages)> <cfset Caller.curPage = ((Caller.startrow -1) / Caller.numPerPage) + 1>
Now for the navigation links:
ColdFusion Syntax (Toggle Plain Text)
<!--- pageNum.cfm ---> <!--- Set Default values ---> <cfparam name="Caller.startRow" default=""> <!--- Numeric ---> <cfparam name="Caller.nextPage" default=""> <!--- Numeric ---> <cfparam name="Caller.prevPage" default=""> <!--- Numeric ---> <cfparam name="Caller.numPerPage" default="20"> <!--- Numeric ---> <cfparam name="Caller.numPages" default=""> <!--- Numeric ---> <cfparam name="Caller.curPage" default=""> <!--- Numeric ---> <cfparam name="Caller.queryName" default=""> <!--- Query ---> <cfparam name="Attributes.forwardImage" default=""> <!--- string ---> <cfparam name="Attributes.backImage" default=""> <!--- string ---> <!--- This variable is used to direct the links to the correct template ---> <cfparam name="Attributes.pageName" default="Index.cfm"> <!--- string ---> <!--- If there is only one page of results, there is no need to show links ---> <cfif Attributes.queryName.RecordCount LT Attributes.numPerPage> <span class="curPage">Page 1 of 1</span> <cfelse> <cfoutput> <!--- If this is not the first page, show a link to the previous ---> <cfif Attributes.prevPage gt 0> <a href="#Attributes.pageName#?startrow=#Attributes.prevPage#" class="pageNum"><cfif Attributes.backImage neq ""><img src="#Attributes.backImage#" border="0" /><cfelse><<Previous Page</cfif></a> </cfif> <!--- If this is the first page, show the page number without a link ---> <cfif Attributes.curPage eq 1> <span class="curPage">1</span> <cfelse> <a href="#Attributes.pageName#?startRow=1" class="pageNum">1</a> </cfif> <!--- Loop through the number of pages and create the links ---> <cfloop index="LoopCount" from="2" to="#Attributes.numPages#"> <!--- If the loopcount is the current page, show the page number without a link ---> <cfif LoopCount eq Attributes.curPage> <span class="curPage">#LoopCount#</span> <cfelse> <cfset pageStart = ((LoopCount - 1 ) * Attributes.numPerPage) + 1> <a href="#Attributes.pageName#?startRow=#pageStart#" class="pageNum">#LoopCount#</a> </cfif> </cfloop> <!--- If we are not on the last page, show a next button ---> <cfif Attributes.nextPage lte Attributes.queryName.RecordCount> <a href="#Attributes.pageName#?startRow=#Attributes.nextPage#" class="pageNum"><cfif Attributes.forwardImage neq ""><img src="#Attributes.forwardImage#" border="0" /><cfelse>Next Page>></cfif></a> </cfif> </cfoutput> </cfif>
So, how do you use it? Like this:
ColdFusion Syntax (Toggle Plain Text)
<!--- Set Default values ---> <cfparam name="startRow" default="1"> <cfparam name="nextPage" default=""> <cfparam name="prevPage" default=""> <cfparam name="numPerPage" default="20"> <cfparam name="numPages" default="0"> <cfparam name="curPage" default="1"> <cf_pageNumSetup queryName="qryQuery" /> <cf_pageNum forwardImage="next.gif" backImage="previous.gif" pageName="Index.cfm" />
Let me know how that works for you...
![]() |
•
•
•
•
•
•
•
•
DaniWeb ColdFusion Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- navigation on button click (JavaScript / DHTML / AJAX)
- Photoshop: create a transparent navigation bar (Web Design Tutorials)
- How to disable back button and backspace using Javascript..? (JavaScript / DHTML / AJAX)
- Navigation (Paging) in HTML table in VB.NET. (VB.NET)
- Question regarding multidimensional array for navigation bar (Graphics and Multimedia)
- navigation within multiple form in VB.NET (VB.NET)
- Problem - IE Synchronize navigation (Web Browsers)
- VB6 submit button sends information to BBChat (Visual Basic 4 / 5 / 6)
- How can i change a picture navigation link after succesfuuly logging in. (ASP.NET)
- bink.nu navigation (HTML and CSS)
Other Threads in the ColdFusion Forum
- Previous Thread: Send a text message to your phone from your site!
- Next Thread: A little help with some coldfusion theroy and code


Linear Mode