Pagination Component for Coldfusion
- currentPage
- perPage
- totalItems
- baseUrl
- numLinks
- wrapperStart
- wrapperEnd
- pageStart
- pageEnd
- previousStart
- previousEnd
- previousMark
- nextStart
- nextEnd
- nextMark
- activeStart
- activeEnd
- config type struct
- template type struct
setPagination
- perPage type numeric
- currentPage type numeric
- totalItems type numeric
<cfparam name="currentPage" default="0">
<cfif structKeyExists(url,'page')>
<cfset currentPage = url.page>
</cfif>
<cfquery name="qCount" dataSource="myBlog">
SELECT COUNT(*) AS count FROM blog
</cfquery>
<cfset config = structNew() >
<cfset config.currentPage = variables.currentPage >
<cfset config.totalItems = qCount.count >
<cfset config.baseUrl = '#CGI.SCRIPT_NAME#?page=' >
<cfset obj = createObject('component','pagination').init(config)>
or use
<cfset obj = createObject('component','pagination').setPagination(2,variables.currentPage,qCount.count)>
<cfquery name="posts" dataSource="myBlog">
SELECT * FROM blog LIMIT #pagi.getOffset#,#pagi.getPerPage()#
</cfquery>
<cfoutput>
my blog query output here
</cfoutput>
<cfoutput>#obj.createLinks()#</cfoutput>