Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
gendrall #1
Page Navigation Help
I have this code that I've been working with for a couple years now. It has
served me well, using it for page numbering one pages that have few results.
The problem now is that if I have a result of, say 2,000 or more and a page
display of about 28, that there are over a hundred pages on the navigation.
Is there a way to limit the number of pages to display a next, previous,
1,2,3,4,5,6,7,8,9,10, ..., next 10 pages, previous 10 pages? Here is the code
that I've been using: <cfquery name='getStuff' datasource='myData'> select *
from myTable order by ID desc </cfquery> <!--- PAGE NUMBER DISPLAY --->
<CFSET RowsPerPage = 28> <cfif #ParameterExists(url.start)# is 'No'> <cfset
curpage = 1> <cfelse> <cfset curPage = 1 + ((#url.start#-1)/#RowsPerPage#)>
</cfif> <CFPARAM NAME='URL.StartRow' DEFAULT='1' TYPE='numeric'> <CFSET
TotalRows = getStuff.RecordCount> <CFSET EndRow = Min(URL.StartRow +
RowsPerPage - 1, TotalRows)> <CFSET StartRowNext = EndRow + 1> <CFSET
StartRowBack = URL.StartRow - RowsPerPage> <cfset PrevStart = Start - MaxRows>
<cfset NextStart = Start + MaxRows> <cfset DisplayPage = Start + MaxRows - 1>
<cfset End = NextStart - 1> <!--- END PAGE NUMBER DISPLAY ---> <cfif
PrevStart GTE 1> <cfoutput><cfset prev=#url.start# - #maxrows#><a
href='#CGI.SCRIPT_NAME#?Start=#prev#&next=#max rows#'>&lt;&lt;Previou
s</a></cfoutput> <cfelse> &lt;&lt;Previous </cfif> <!--- Simple 'Page'
counter, starting at first 'Page' ---> <cfset thispage = 1> <!--- Loop thru
row numbers, in increments of RowsPerPage ---> <cfloop from='1'
to='#TotalRows#' step='#RowsPerPage#' index='PageRow'> <!--- Detect whether
this 'Page' currently being viewed ---> <cfset iscurrentpage = (pagerow gte
url.startrow) and (pagerow lte endrow)> <!--- If this 'Page' is current page,
show without link ---> <cfif iscurrentpage> | <cfoutput><a
href='#CGI.SCRIPT_NAME#?Start=#PageRow#&next=# maxrows#'><cfif #curpage# is
'#thisPage#'><b><font
size='2'>#ThisPage#</font></b><cfelse>#ThisPage#</cfif></a></cfoutput> <!---
Otherwise, show with link so user can go to page ---> <cfelse> <cfoutput> <a
href='#CGI.SCRIPT_NAME#?Start=#PageRow#&next=# maxrows#'><cfif #curpage# is
'#thisPage#'><b><font
size='2'>#ThisPage#</font></b><cfelse>#ThisPage#</cfif></a> </cfoutput> </cfif>
| <!--- Increment ThisPage variable ---> <cfset thispage = thispage + 1>
</cfloop> <cfif NextStart LTE getStuff.RecordCount> <cfoutput><A
HREF='#CGI.SCRIPT_NAME#?start=#nextstart#&next =#maxrows#'>Next
&gt;&gt;</a></cfoutput> <cfelse> Next &gt;&gt; </cfif>
gendrall Guest
-
Navigation on detail page. Please help
I have created a master page that is for my picture gallery I am using the thumbnail as a link to my detail page. On my detail page I am showing... -
Adding Navigation to the Details Page
Hi, Could someone help, i am wanting to add navigation to my details page to prevent the user from having to move backwards and forwards between... -
Recordset page navigation
Hi , I have a page that get 1000 records and I?m displaying it 10 records a page. I want to use page numbers line 1,2,3, ...as my navigation instead... -
Page Navigation?
how to do this: using "Page numbers" as mode but change the "..." on the buttom of the pages to "previous" and "next". thanks. -
Best way to make navigation bar on each page?
Design your navigation bar, (i think you're working in Dreamweaver) when you finish select it, then make it a Library. Libraries must be inserted... -
MrDippy #2
Re: Page Navigation Help
I'm not sure what you mean. Do you only want to show 5 pages at most of data
with 28 records each on them? You could just right right a simple condition
statement saying if the endrow variable is >= 500 or whatever you want then
don't show the next or pervious href tags.
MrDippy Guest
-
gendrall #3
Re: Page Navigation Help
If I have lots of pages, I dont' want to display 162 page numbers in my page
nav bar. I would like to be able to display about 10 or so and then giving the
option to go to the next 10 pages. Sort of the way google does it with only
showing 19 page numbers.
gendrall Guest
-
MrDippy #4
Re: Page Navigation Help
okay so you would want your code to look something like this <CFIF TotalRows
GT 10 AND ShowAllPages IS 'False'> <CFSET TotaRows = 10> </CFIF> <cfloop
from='1' to='#TotalRows#' step='#RowsPerPage#' index='PageRow'> code to list
page numbers here <a href='thispage.cfm?showAllPages=true'>Show All Pages</a>
</CFLOOP> <cfif NextStart LTE getStuff.RecordCount AND (PageRow LTE 10 AND
ShowAllPages is 'false') > <cfoutput>Next >></cfoutput> <cfelse> Next >> </cfif>
MrDippy Guest
-
gendrall #5
Re: Page Navigation Help
Still not working. It didn't do anything to the page numbers except remove all
put one. I think what I'm going to do is limit the number of results to the
top 500 in the query and then give the option for a more refined search.
gendrall Guest
-
marmsV4L #6
Re: Page Navigation Help
This is a really good free custom tag that does recordset 'pagination' much
like you describe. Works like Google's where it limits then number of pages in
the navigation bar, but as you pan over it gives you more page numbers. I
modified this one into a CFC for my own use.
[url]http://www.cornfeed.com/index.cfm/go/products,cfpagelist[/url]
marmsV4L Guest
-
gendrall #7
Re: Page Navigation Help
That looks like it could work. Thank you! Much appreciated.
Sorry for the late response.
Cheers,
Rome
gendrall Guest



Reply With Quote

