You want the function is here, attention is pagelist, this is one of the CCF core code, I believe that the code is less than the pagelist less. There is absolutely no discount on the function. including PageList home/Last page, up/down page, page number can set display number, This avoids the number of a lot of up to pull pagelist long ....
Define the following variables in the source file that calls PageList:
<cfset Rowsperpage=10> <!---the number of records displayed per page----->
<cfparam name= "Url.startrow" default= "1" type= "Numeric" >
<cfset totalrows=newarticle. Recordcount>
<cfset endrow=min (url.startrow+rowsperpage-1,totalrows) >
<cfset startrownext=endrow+1>
<cfset startrowback=url.startrow-rowsperpage>
PageList code: You can keep it as a Web page, and then insert it into the place you want to display. Change the name of the query variable to your own query variable name.
<cfsetting enablecfoutputonly= "Yes" ><!---compressed white space to improve performance--->
<cfparam name= "page" default=1 type= "Numeric" > <!---Initialize page number--->
<cfparam name= "n" default=7 type= "Numeric" > <!---settings How many pages can be displayed--->
<cfset min = page-int (N/2) >
<cfset max = Page+int (N/2) >
<cfif min Lt 1>
<cfset max = max-(min-1) >
<cfset min = 1>
</cfif>
<cfif Max GT Ceiling (newarticle.recordcount/rowsperpage) >
<cfset min = Min-(max-ceiling (newarticle.recordcount/rowsperpage)) >
<cfset max = Ceiling (newarticle.recordcount/rowsperpage) >
</cfif>
Code Copy Box
The following is a reference fragment:
<cfsetting enablecfoutputonly= "Yes" ><!---compressed white space to improve performance--->
<cfparam name= "page" default=1 type= "Numeric" > <!---Initialize page number--->
<cfparam name= "n" default=7 type= "Numeric" > <!---settings How many pages can be displayed--->
<cfset min = page-int (N/2) >
<cfset max = Page+int (N/2) >
<cfif min Lt 1>
<cfset max = max-(min-1) >
<cfset min = 1>
</cfif>
<cfif Max GT Ceiling (newarticle.recordcount/rowsperpage) >
<cfset min = Min-(max-ceiling (newarticle.recordcount/rowsperpage)) >
<cfset max = Ceiling (newarticle.recordcount/rowsperpage) >
</cfif>
GAME over.
Explain some of the control statements that are not commented on above:
<cfparam name= "n" default=7 type= "Numeric" >
This setting defaults to 7, which means that when you browse the 12 records, you will see 9 10 11 [12] 13 14 15
Count, is not 7, this is an important part, you can also set to even, but the effect is not how good, unbalanced.
In addition, there is the function of automatic hiding. For example, I am on the last page, not the last and next page.
Again, you have to replace the name of your own query variable with newarticle.recordcount, the variable name I set. It is best to replace it all at once with find/replace.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.