Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,825 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,006 people online right now. Registration is fast and FREE... Join Now!




Limit pages shown in navigation

 
Reply to this topicStart new topic

Limit pages shown in navigation, Pagination

dallasmcintosh
17 Aug, 2008 - 12:19 PM
Post #1

New D.I.C Head
*

Joined: 29 Apr, 2008
Posts: 3


My Contributions
Hi,

I have recently revisited using pagination for records I have stored on my site. The problem is it returns more than I'm after and looks clumsy (ie 1,2,3,4,5,6,7,8,9,10,11 etc). I would just like to have 5 pages shown at one time, similar to how google and facebook use theirs.

I'm new to using coldfusion and would like some help if possible. Relevant code is below... Please help

CODE

<cfparam name="StartVal" default="1">
<cfparam name="Page" default="1">
<cfparam name="CurrGroup" default="ItemCategoryName">

<cfif NOT SearchDetail>
    <cfset CurrListQTY=20>
</cfif>

<!--- http://tutorial405.easycfm.com/ --->
<cfparam name="StartPage" default="1">
<cfset PageShown = 10>
<!--- End --->

<cfif CurrItemcategoryID NEQ 0>
    <cfset CurrListQty=10>
<cfelseif CurrListQty EQ "All">
    <cfset CurrListQty=#itemList.recordcount#>
</cfif>

<cfset StartVal=((page*CurrListQty)-CurrListQty)+1>
<cfset EndVal=StartVal+CurrListQty-1>
<cfset InitPageQty=itemlist.recordcount/CurrListQty>

<cfif InitPageQty GT Round(InitPageQty)>
    <cfset PageQty = Round(InitPageQty+1)>
<cfelse>
    <cfset PageQty = Round(InitPageQty)>
</cfif>

<!--- http://tutorial405.easycfm.com/ --->
<cfset EndPage = StartPage + PageShown - 1>
<!--- End --->

<div class="itemNavigation" align="right" style="padding-bottom:8px">
    <cfif CurrItemcategoryID NEQ 0>
    <cfif page GT 1>
      <a href="index.cfm?CurrBrandID=#CurrBrandID#&CurrItemcategoryID=#CurrItemcategoryID#&page=1">First</a>
      <a href="index.cfm?CurrBrandID=#CurrBrandID#&CurrItemcategoryID=#CurrItemcategoryID#&page=#Page-1#">Prev</a>
    </cfif>
                                
    <cfloop from="1" to="#PageQty#" index="p">
      <a href="index.cfm?CurrBrandID=#CurrBrandID#&CurrItemcategoryID=#itemcategoryid#&page=#p#" target="_parent">
    <cfif page EQ p>
      <font color=red>
      </cfif>#p#
      <cfif page EQ p>
      </font>
    </cfif></a> 
    </cfloop>
    <cfif Page * CurrListQty LT itemlist.recordcount>
      <a href="index.cfm?CurrBrandID=#CurrBrandID#&CurrItemcategoryID=#CurrItemcategoryID#&page=#Page+1#">Next</a>
    </cfif>
    <cfif Page LT PageQty>
      <a href="index.cfm?CurrBrandID=#CurrBrandID#&CurrItemcategoryID=#CurrItemcategoryID#&page=#p-1#">End</a>
    <cfelse>
    </cfif>
    <cfelse>
    <div class="SeeMore" align="right" style="padding-bottom:8px">
      <a href="index.cfm?CurrBrandID=#CurrBrandID#&CurrItemcategoryID=#itemcategoryid#&page=1" target="_parent">View All #ItemCategoryname# Titles</a>
    </div>
    </cfif>
    </div>
    </td>
    </tr>
    </cfoutput>


Thanks for your help in advance... Cheers
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 03:16PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month