<<Previou s <<Previous | #ThisPage##ThisPage# #ThisPage##ThisPage# | Next >> Next >> [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => gendrall [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> Page Navigation Help - Coldfusion - Advanced Techniques

Page Navigation Help - Coldfusion - Advanced Techniques

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 ...

  1. #1

    Default 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#&amp;next=#max rows#'>&amp;lt;&amp;lt;Previou
    s</a></cfoutput> <cfelse> &amp;lt;&amp;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#&amp;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#&amp;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#&amp;next =#maxrows#'>Next
    &amp;gt;&amp;gt;</a></cfoutput> <cfelse> Next &amp;gt;&amp;gt; </cfif>

    gendrall Guest

  2. #2

    Default 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

  3. #3

    Default 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

  4. #4

    Default 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

  5. #5

    Default 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

  6. #6

    Default 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

  7. #7

    Default Re: Page Navigation Help

    That looks like it could work. Thank you! Much appreciated.

    Sorry for the late response.

    Cheers,
    Rome
    gendrall Guest

Similar Threads

  1. Navigation on detail page. Please help
    By DerekD in forum Coldfusion Database Access
    Replies: 0
    Last Post: March 14th, 02:19 PM
  2. Page Navigation in Learning Site
    By FyrByrd in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 0
    Last Post: August 2nd, 02:15 PM
  3. Recordset page navigation
    By kaifanun in forum Macromedia ColdFusion
    Replies: 0
    Last Post: March 3rd, 09:44 PM
  4. Page Navigation?
    By LL in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: February 4th, 09:39 PM
  5. Best way to make navigation bar on each page?
    By Juan in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 11th, 02:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •