alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

jforum example source code file (search_pagination.ftl)

This example jforum source code file (search_pagination.ftl) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - jforum tags/keywords

always, intermediate, intermediate, next, next, previous, previous, write, write

The jforum search_pagination.ftl source code

<#function moderationParams>
	<#assign params = ""/>

	<#if (searchArgs.keywords?size > 0)><#assign params = params +"&search_keywords="+ searchArgs.rawKeywords()/>
	<#if (searchArgs.forumId > 0)><#assign params = params +"&search_forum="+ searchArgs.forumId/>
	<#if (searchArgs.author > 0)><#assign params = params +"&search_author="+ searchArgs.author/>
	<#if (searchArgs.matchType?default("")?length > 0)><#assign params = params +"&match_type="+ searchArgs.matchType/>
	<#if (searchArgs.orderDir?default("")?length > 0)><#assign params = params +"&sort_dir="+ searchArgs.orderDir/>
	<#if (searchArgs.orderBy?default("")?length > 0)><#assign params = params +"&sort_by="+ searchArgs.orderBy/>

	<#return params/>
</#function>

<#macro searchPagination>
	<#if (totalRecords > recordsPerPage)>
		<#assign baseUrl = contextPath +"/jforum" + extension + "?module=search&action=search"/>
		<#assign baseUrl = baseUrl + moderationParams()/>

		<div class="pagination">
		<#assign link = ""/>

		<#-- ------------- -->
		<#-- Previous page -->
		<#-- ------------- -->
		<#if (thisPage > 1)>
			<#assign start = (thisPage - 2) * recordsPerPage/>
			<a href="${baseUrl}&start=${start}">◄
		</#if>

		<#if (totalPages > 10)>
			<#-- ------------------------------ -->
			<#-- Always write the first 3 links -->
			<#-- ------------------------------ -->
			<#list 1 .. 3 as page>
				<@pageLink page, baseUrl/>
			</#list>

			<#-- ------------------ -->
			<#-- Intermediate links -->
			<#-- ------------------ -->
			<#if (thisPage > 1 && thisPage < totalPages)>
				<#if (thisPage > 5)>...

				<#if (thisPage > 4)>
					<#assign min = thisPage - 1/>
				<#else>
					<#assign min = 4/>
				</#if>

				<#if (thisPage < totalPages - 4)>
					<#assign max = thisPage + 2/>
				<#else>
					<#assign max = totalPages - 2/>
				</#if>

				<#if (max >= min + 1)>
					<#list min .. max - 1 as page>
						<@pageLink page, baseUrl/>
					</#list>
				</#if>

				<#if (thisPage < totalPages - 4)>...
			<#else>
				<span class="gensmall">...
			</#if>

			<#-- ---------------------- -->
			<#-- Write the last 3 links -->
			<#-- ---------------------- -->
			<#list totalPages - 2 .. totalPages as page>
				<@pageLink page, baseUrl/>
			</#list>
		<#else>
			<#list 1 .. totalPages as page>
				<@pageLink page, baseUrl/>
			</#list>
		</#if>

		<#-- ------------- -->
		<#-- Next page -->
		<#-- ------------- -->
		<#if (thisPage < totalPages)>
			<#assign start = thisPage * recordsPerPage/>
			<a href="${baseUrl}&start=${start}">►
		</#if>

		<a href="#goto" onClick="return overlay(this, 'goToBox', 'rightbottom');">${I18n.getMessage("ForumIndex.goToGo")}
		<div id="goToBox">
			<div class="title">${I18n.getMessage("goToPage")}...
<div class="form"> <input type="text" style="width: 50px;" id="pageToGo"> <input type="button" value=" ${I18n.getMessage("ForumIndex.goToGo")} " onClick="goToAnotherPageSearch(${totalPages}, ${recordsPerPage}, '${baseUrl}');"> <input type="button" value="${I18n.getMessage("cancel")}" onClick="document.getElementById('goToBox').style.display = 'none';"> </div> </div> </div> </#if> </#macro> <#macro pageLink page baseUrl> <#assign start = recordsPerPage * (page - 1)/> <#if page != thisPage> <#assign link>${page} <#else> <#assign link>${page} </#if> ${link} </#macro>

Other jforum examples (source code examples)

Here is a short list of links related to this jforum search_pagination.ftl source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.