|
PageListTemplatesDefault page list templatesPmWiki's default templates for page lists are in Site.PageListTemplates, which is replaced during upgrades.
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
Administrators can change those locations by using the $FPLTemplatePageFmt variable. If the template is on the current page, the current page must be saved for changes involving the template to show up (preview alone will not work). Custom page list templatesCustom templates are used in the same way as default templates: by referencing the desired format with the
See Cookbook:PagelistTemplateSamples for examples of custom pagelist formats. Creating page list templatesA pagelist template contains standard pmwiki markup.
Special referencesDuring the page list iteration pmwiki sets 3 special page references: =, < and >.
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:
See also page variable special references.
Page list template special markupPagelist templates may have special sections
to specify output for the first or last page in the list or a group (use There's also a
These allow Pagelist templates to be easily separated into "sections"
First, Each, Last, NoneThe 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 So, a pagelist template can specify: (:template first:) Pages in the list: (:template each:) * [[{=$FullName}]] [-{{=$FullName}$:Summary}-] (:template last:) Displayed {$$PageCount} pages. In addition, the "first" and "last" options can have control break
(:template first {=$Group}:) (:template last {=$Group}:) Thus, instead of writing control breaks using directives, as in (:if ! equal {<$Group} {=$Group}:) Group: {=$Group} (:ifend:) * [[{=$FullName}]] one can now write (:template first {=$Group}:) Group: {=$Group} (:template each:) * [[{=$FullName}]] Page text variables and page variables can also be used, for example (:template default $:Maintainer=- order=$:Maintainer,name:) (:template first {=$:Maintainer}:) Default optionsIn addition, a template may specify default options to be used
[[#bytitle]] (:template defaults order=title:) * [[{=$FullName}|+]] [[#bytitleend]] Then an author could write (:pagelist fmt=#bytitle:) and the
To specify multiple parameters to an option enclose the parameters in double quotes, eg to sort by a page text variable and then the page name (:template defaults order="$:Database,name" :)
Examples
So, we have: [[#template]] (:template defaults order=name:) (:template first:) Pages ordered by group (:template first {=$Group}:) Pages in group [[{=$Group}/]] (:template each:) * [[{=$FullName}]] (:template last {=$Group}:) {=$Group} contains {$$GroupPageCount} pages. (:template last:) {$$PageCount} pages total. [[#templateend]] Page list template additional page variablesAdditional 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. RedirectTo 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: (:template last:) (:if equal {$$PageCount} 1:)(:redirect {=$FullName}:)(:ifend:) Closure of markupAny open tables, divs, or other
For example a table generated by the (:cell:)
Note that the (:table:) directive doesn't actually start a new table,
UsageIt is advisable to not modify the page Site.PageListTemplates directly so that you will still benefit from upgrades.
Other recipesIn addition, the Cookbook has other recipes for special This page may have a more recent version on pmwiki.org: PmWiki:PageListTemplates, and a talk page: PmWiki:PageListTemplates-Talk. |