PageListTemplates

PmWiki's default templates for page lists are in Site.PageListTemplates, which is replaced during upgrades.
These default templates can be supplemented or overridden with custom templates stored in other locations.

If the page name is not specified as part of the template name, PmWiki's default configuration looks for templates in the following locations in the following order

Creating page list templates

A pagelist template contains standard pmwiki markup.
When creating pagelist output, pmwiki iterates over each page returned from the pagelist and will include the pagelist template markup once for every page in the list.

Special references

During the page list iteration pmwiki sets 3 special page references: =, < and >.
These special page references are updated on each pagelist iteration and can be used with the page variables syntax, such as {=$variable}, to define a pagelist template which will format the pagelist output. The meaning of the special references are:

=

current page

so {=$Title}

displays the title of the current page in the iteration

<

previous page

so {<$Group}

displays the group of the previous page in the iteration

>

next page

so {>$Name}

displays the name of the next page in the iteration

The > and < references are most useful to help structure pagelist output before and after the actual pagelist. Some common tests used to structure pagelist output are:

(:template none:)
whose content will appear if no page was found (from version 2.2.5).

These allow Pagelist templates to be easily separated into "sections"
that are included or not included in the output based on a variety of
conditions. These are intended to be improved versions of the
(:if ...:) conditions that have traditionally been used to control
pagelist output (however, the (:if:) conditions still work as before).

First, Each, Last, None

The simplest versions of the directives are:

(:template first:) # markup to display only for first page in list
(:template ! first:) # markup to display for every page in list but the first
(:template each:) # markup to display for each page in list
(:template last:) # markup to display only on last page in list
(:template ! last:) # markup to display for every page in list but the last
(:template none:) # markup to display only if no pages were found

In addition, the "first" and "last" options can have control break
arguments that identify markup to be displayed on the first or last
page within a particular control section. For example, to specify
markup to be displayed upon reaching the first or last page of
a group, one can use

Page list template additional page variables

Additional Page Variables that are only available during pagelist are:

{$$PageCount} The current page count of this iteration
{$$GroupCount} The current group count of this iteration
{$$GroupPageCount} The current page count within the current group of this iteration

{$$option} The argument option values from (:pagelist:)

Use of {$$option}: For example {$$trail} returns the page name entered in the trail= option of the pagelist directive. You can make up custom "options" with no other purpose than being displayed in the pagelist.

Redirect

To enable searches that return only one page to automatically redirect to that page add the following to a pagelist template where the "jump to a page" functionality is desired:

Closure of markup

Any open tables, divs, or other
structures inside of (:pagelist:) are, by default, automatically closed at the
end of the pagelist command. In other words, (:pagelist:) acts like
its own complete page, as opposed to generating markup that is then
inserted into the enclosing page.

For example a table generated by the (:cell:)
directive in the first (:pagelist:) command is automatically closed
at the end of the pagelist. The (:cell:) in the second (:pagelist:)
command then starts a new table.

Note that the (:table:) directive doesn't actually start a new table,
it's the (:cell:) or (:cellnr:) directive that does it. All that the
(:table:) directive does is set attributes for any tables that follow.