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