fn: paginate.template

[contents]

Contents

Syntax

The syntax for paginate.template calls is:

f++:  
paginate.template
{
	//template code
}

n++:  
@paginate.template
{
	//template code
}

Description

The paginate.template function is for, when using pagination, specifying the template code used when generating each page, it takes zero parameters and is followed by a block of n++ code.

Note: Specifying a template for pagination is optional, the default template is "$[paginate.page]" which simply injects each item separated by the paginate separator.

Note: The hard-coded constants available for pagination are listed here.

See here for some blog templates which use pagination for the posts table, specifically see here (demo) for an example of pagination code.

Note: Nift will skip to the first non-whitespace (ie. to the first character that is not a space, tab or newline) after a paginate.template call and inject it to the output file where the call started. If you want to prevent Nift from doing this put a '!' after the call, eg.:

@paginate.template
{
	# block
}!

n++ example

Example of paginate.template being used with n++:

@paginate.template
{
	<p>
		@if{!s}($[paginate.page_no] > 1)
		{
			<a href="@pathtopageno(@`$[paginate.page_no]-1`)">previous</a>
		}
		@if{!s}($[paginate.page_no] < $[paginate.no_pages])
		{
			<a href="@pathtopageno(@`$[paginate.page_no]+1`)">next</a>
		}
	</p>

	$[paginate.page]
}