navigation button

Thread Solved

Join Date: Nov 2007
Posts: 46
Reputation: nish88 is an unknown quantity at this point 
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

navigation button

 
0
  #1
Jul 14th, 2008
have anyone ever creates navigation buttons such as next,previous in coldfusion?

can i see ours if you have created one?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 72
Reputation: cmhampton is an unknown quantity at this point 
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

 
0
  #2
Jul 14th, 2008
Based on query data? If so yes, but I don't have it with me at the moment. I'll get back to you.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 46
Reputation: nish88 is an unknown quantity at this point 
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

Re: navigation button

 
0
  #3
Jul 15th, 2008
ya its based on query.
so thanks in advance..
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 72
Reputation: cmhampton is an unknown quantity at this point 
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

 
0
  #4
Jul 15th, 2008
Are you permitted by your hosting company to use custom tags?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 46
Reputation: nish88 is an unknown quantity at this point 
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

Re: navigation button

 
0
  #5
Jul 16th, 2008
ya am permitted
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 72
Reputation: cmhampton is an unknown quantity at this point 
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

 
0
  #6
Jul 16th, 2008
OK. I have a custom tag that will pretty much do everything for you. I'll post it in the morning when I get back to work.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 72
Reputation: cmhampton is an unknown quantity at this point 
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

 
0
  #7
Jul 16th, 2008
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:

  1. <!--- pageNumSetup.cfm --->
  2.  
  3. <cfscript>
  4. // round page number variable up
  5. function roundPageNum(number) {
  6.  
  7. var x = 0;
  8.  
  9. x = Int(number);
  10.  
  11. if(number - x neq 0) {
  12. x = x + 1;
  13. }
  14.  
  15. return x;
  16. }
  17. </cfscript>
  18.  
  19. <!--- Set Default values --->
  20. <cfparam name="Caller.startRow" default="1">
  21. <cfparam name="Caller.nextPage" default="">
  22. <cfparam name="Caller.prevPage" default="">
  23. <cfparam name="Caller.numPerPage" default="20">
  24. <cfparam name="Caller.numPages" default="0">
  25. <cfparam name="Caller.curPage" default="1">
  26. <cfparam name="Attributes.queryName" default="">
  27.  
  28. <!--- Set values for previous and next pages --->
  29. <cfset Caller.nextPage = Caller.startRow + Caller.numPerPage>
  30. <cfset Caller.prevPage = Caller.startRow - Caller.numPerPage>
  31.  
  32. <!--- Determine the total number of pages for this search --->
  33. <cfset Caller.numPages = Attributes.queryName.RecordCount / Caller.numPerPage >
  34. <cfset Caller.numPages = roundPageNum(Caller.numPages)>
  35. <cfset Caller.curPage = ((Caller.startrow -1) / Caller.numPerPage) + 1>

Now for the navigation links:

  1. <!--- pageNum.cfm --->
  2.  
  3. <!--- Set Default values --->
  4. <cfparam name="Caller.startRow" default=""> <!--- Numeric --->
  5. <cfparam name="Caller.nextPage" default=""> <!--- Numeric --->
  6. <cfparam name="Caller.prevPage" default=""> <!--- Numeric --->
  7. <cfparam name="Caller.numPerPage" default="20"> <!--- Numeric --->
  8. <cfparam name="Caller.numPages" default=""> <!--- Numeric --->
  9. <cfparam name="Caller.curPage" default=""> <!--- Numeric --->
  10. <cfparam name="Caller.queryName" default=""> <!--- Query --->
  11. <cfparam name="Attributes.forwardImage" default=""> <!--- string --->
  12. <cfparam name="Attributes.backImage" default=""> <!--- string --->
  13.  
  14. <!--- This variable is used to direct the links to the correct template --->
  15. <cfparam name="Attributes.pageName" default="Index.cfm"> <!--- string --->
  16.  
  17. <!--- If there is only one page of results, there is no need to show links --->
  18. <cfif Attributes.queryName.RecordCount LT Attributes.numPerPage>
  19. <span class="curPage">Page 1 of 1</span>
  20. <cfelse>
  21.  
  22. <cfoutput>
  23.  
  24. <!--- If this is not the first page, show a link to the previous --->
  25. <cfif Attributes.prevPage gt 0>
  26. <a href="#Attributes.pageName#?startrow=#Attributes.prevPage#" class="pageNum"><cfif Attributes.backImage neq ""><img src="#Attributes.backImage#" border="0" /><cfelse>&lt;&lt;Previous Page</cfif></a>&nbsp;&nbsp;
  27. </cfif>
  28.  
  29. <!--- If this is the first page, show the page number without a link --->
  30. <cfif Attributes.curPage eq 1>
  31. <span class="curPage">1</span>
  32. <cfelse>
  33. <a href="#Attributes.pageName#?startRow=1" class="pageNum">1</a>
  34. </cfif>
  35.  
  36. <!--- Loop through the number of pages and create the links --->
  37. <cfloop index="LoopCount" from="2" to="#Attributes.numPages#">
  38.  
  39. <!--- If the loopcount is the current page, show the page number without a link --->
  40. <cfif LoopCount eq Attributes.curPage>
  41. <span class="curPage">#LoopCount#</span>
  42. <cfelse>
  43. <cfset pageStart = ((LoopCount - 1 ) * Attributes.numPerPage) + 1>
  44. <a href="#Attributes.pageName#?startRow=#pageStart#" class="pageNum">#LoopCount#</a>
  45. </cfif>
  46.  
  47. </cfloop>
  48.  
  49. <!--- If we are not on the last page, show a next button --->
  50. <cfif Attributes.nextPage lte Attributes.queryName.RecordCount>
  51. &nbsp;&nbsp;<a href="#Attributes.pageName#?startRow=#Attributes.nextPage#" class="pageNum"><cfif Attributes.forwardImage neq ""><img src="#Attributes.forwardImage#" border="0" /><cfelse>Next Page&gt;&gt;</cfif></a>
  52. </cfif>
  53.  
  54. </cfoutput>
  55. </cfif>

So, how do you use it? Like this:

  1. <!--- Set Default values --->
  2. <cfparam name="startRow" default="1">
  3. <cfparam name="nextPage" default="">
  4. <cfparam name="prevPage" default="">
  5. <cfparam name="numPerPage" default="20">
  6. <cfparam name="numPages" default="0">
  7. <cfparam name="curPage" default="1">
  8.  
  9. <cf_pageNumSetup queryName="qryQuery" />
  10.  
  11. <cf_pageNum forwardImage="next.gif" backImage="previous.gif" pageName="Index.cfm" />

Let me know how that works for you...
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 46
Reputation: nish88 is an unknown quantity at this point 
Solved Threads: 0
nish88's Avatar
nish88 nish88 is offline Offline
Light Poster

Re: navigation button

 
0
  #8
Jul 29th, 2008
hiiii
ya the navigation button works correctly and perfectly.
thnk
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 72
Reputation: cmhampton is an unknown quantity at this point 
Solved Threads: 10
cmhampton's Avatar
cmhampton cmhampton is offline Offline
Junior Poster in Training

Re: navigation button

 
0
  #9
Jul 29th, 2008
Anytime. Glad to help.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC