Copy link to clipboard
Copied
HI ,
I have been trying to limit the output of page totals in my pagination code so I can use it at the top of the page. I grabbed the existing code from a tutorial and it works fine. I tried simply settting a page total variable and outputting , but I do realize it's a little ore compicated than that. Any help will be greatly appreciated.
<div style="padding-top:10px;">
<p> </p>
</div>
<p align="center" class="breadcrumb">
Top of page setting some vars :
<!--- set up pagination --->
<cfset perpage=12>
<cfparam name="url.start" default="1">
<cfif not isNumeric(url.start) or url.start lt 1 or url.start gt qry_prod.recordCount or round(url.start) neq url.start>
<cfset url.start = 1>
</cfif>
<!--- outputting query reslults table rows of product stuff with maxrows set to perpage var--->
<table>
<tr>
<td> ect ...........................
<!--- Here I employ the pageination code , displays at bottom of page --- >
[
<cfif url.start gt 1>
<cfset link = cgi.script_name & "?fuseaction=products&action=cat&id=#url.id#&start=" & (url.start - perpage)>
<cfoutput><a href="#link#">Previous Page</a></cfoutput>
<cfelse>
Previous Page
</cfif>
|
<!--- Start Page Number --->
<cfset pageCount = 1>
<cfset pageLink = 1>
<cfset totalPages = Ceiling(qry_prod.recordCount / perpage)>
<cfloop index="c" from="1" to="#totalPages#">
<cfoutput>
<a href="?fuseaction=products&action=cat&id=#url.id#&start=#pageLink#">#pageCount#</a>
</cfoutput>
<cfset pageCount = pageCount + 1>
<cfset pageLink = pageLink + perpage>
</cfloop>
|
<!--- End Page Number --->
<cfif (url.start + perpage - 1) lt qry_prod.recordCount>
<cfset link = cgi.script_name & "?fuseaction=products&action=cat&id=#url.id#&start=" & (url.start + perpage)>
<cfoutput><a href="#link#">Next Page</a></cfoutput>
<cfelse>
Next Page
</cfif>
]
</p>
Thanks ,
Steve
Copy link to clipboard
Copied
Despite reading it twice, I still do not understand the question 😉 What is the code doing wrong, and what do you want it to do instead?
Copy link to clipboard
Copied
The code isn't doing anything wrong. I simply wish to append the functionality by limiting the pageCount output so that if a have 40 ,50 even 100 total pages, they won't spread acroos the page. Sounds simple enough , but I am kinda stumped.
Copy link to clipboard
Copied
The code isn't doing anything wrong.
In your words, wrong is: "the total pages are ... spread acroos the page". You would like the output to be different (somehow).
Without actually running your code ... I would guess your results are something like:
Page 1, Page 2, Page 3, Page 4, Page N, Page 40
What do you want to see instead of that?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Ah, thanks. Have a look at http://paginationcfc.riaforge.org/. As you can see in the demo url, selecting the "google" style lets you implement that kind of pagination.
Copy link to clipboard
Copied
Thanks ... easy to implement. Works great!
Copy link to clipboard
Copied
Steevo2,
How did you implement the Google style into your code above? Could you post your updated code? Thanks.
Andy