Skip to content

Instantly share code, notes, and snippets.

@coreysyms
Last active March 10, 2017 16:08
Show Gist options
  • Save coreysyms/05ed89800a7a40788ce4ec25c3761a27 to your computer and use it in GitHub Desktop.
Save coreysyms/05ed89800a7a40788ce4ec25c3761a27 to your computer and use it in GitHub Desktop.
<!---
getQuery() query Returns the entire recordset.
getRecordSet() query Returns the entire recordset.
getTotalRecords() numeric Returns the number of records in the entire recordset.
getPageFrom() numeric Get the start page of the pagination loop.
getPageTo() numeric Get the end page of the pagination loop.
getRecordsPerPage() numeric Returns the number of records to be displayed per page.
getCurrentPage() numeric Get the current page.
getTotalPages() numeric Get the total number of pages.
getFirstPage() numeric Get the first page in the pagination loop.
getLastPage() numeric Get the last page in the pagination loop.
getRecordFrom() numeric Get the first row of the recordset for the current page of the pagination.
getRecordTo() numeric Get the last row of the recordset for the current page of the pagination.
getCurrentRow() numeric Get the current row of the recordset for the current page of the pagination.
getPaginationID() string Get the PaginationID for this instance of the pagination.
getNextRowAsStruct() struct Converts the current row of the recordset to a structure.
--->
<cfsetting enablecfoutputonly="true" />
<cfoutput>
<!--- it is better to use getLink than renderLink because I need more robust returns and UI --->
<cfif getPageTo() GT 1>
<cfset previousButton = getLink("previous")>
<cfset nextButton = getLink("next")>
<div class="row">
<div class="column">
<ul class="pagination text-center" role="navigation" aria-label="Pagination">
<cfif previousButton.bDisabled>
<li class="pagination-previous disabled">&laquo;</li>
<cfelse>
<li class="pagination-previous"><a href="#previousButton.href#">&laquo;</span></a></li>
</cfif>
<cfloop from="#getPageFrom()#" to="#getPageTo()#" index="i">
<cfset pageButton = getLink(i)>
<cfif pageButton.page EQ getCurrentPage()>
<li class="current hide-for-small-only"><span class="show-for-sr">You're on page</span> #pageButton.page#</li>
<cfelse>
<li class="hide-for-small-only"><a href="#pageButton.href#" aria-label="Page #pageButton.page#">#pageButton.page#</a></li>
</cfif>
</cfloop>
<li class="show-for-small-only">
Page
<form>
<select name="menu" onChange="window.document.location.href=this.options[this.selectedIndex].value;">
<cfloop from="#getPageFrom()#" to="#getPageTo()#" index="i">
<cfset pageButton = getLink(i)>
<option value="#getLink(i).href#" <cfif pageButton.page EQ getCurrentPage()>selected</cfif>>#pageButton.page#</option>
</cfloop>
</select>
</form>
of #getTotalPages()#
</li>
<cfif nextButton.bDisabled>
<li class="pagination-next disabled">&raquo;</li>
<cfelse>
<li class="pagination-next"><a href="#nextButton.href#">&raquo;</a></li>
</cfif>
</ul>
</div>
</div>
</cfif>
</cfoutput>
<cfsetting enablecfoutputonly="false" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment