Pagelist
The pagelist contains by default all pages which are not hidden and therefore has no defined type. Changing the pagelist type to one of the following available types will update the selection of pages accordingly. The main purpose of this object is to provide an easy way of iterating over a defined set of pages using a foreach loop.
Types
- false
- The default type. All pages.
- "children"
- Direct children of a given page. The parent page can be defined by using the
context
parameter. - "siblings"
- All siblings of the current page.
- "related"
- All pages having tags in common with the current page.
- "breadcrumbs"
- A breadcrumb trail to the current page.
Sorting and Filtering
A paglist can also be sorted and filtered, depending on its type. To configure the list, you can use the newPagelist and the pagelist functions.
Take a look at this pagelist template to get started!
<@ newPagelist {
type: 'children',
sort: 'date desc',
filter: @{ ?filter }
} @>
<@ foreach in pagelist @>
...
@{ title }
...
<@ end @>
Filtering by any Variable using Regular Expressions
Aside from the option to filter a pagelist by tags using the filter
parameter, there is also a more generic way of defining a selection of pages using the match
parameter. The match
parameter allows for filtering the list of pages by one or more variables using regular expressions. The value of the match
parameter has to be a JSON formatted string. Note that in the example below the JSON string is therefore wrapped in single quotes.
<@ newPagelist {
match: '{"url": "#(/work|/blog)#", ":level": "/2/"}'
} @>
It is also possible to use any variable inside the regex to keep a pagelist modifiable by users.
<@ newPagelist {
match: '{"url": "@{ regex }", ":level": "/2/"}'
} @>
Related Runtime Variables
There are two specific runtime variables associate with current configuration of the pagelist object.
- :pagelistCount
- The number of pages in the current pagelist — ignoring the pagelist limit and pagination.
- :pagelistDisplayCount
- The number of pages actually displayed.
- :paginationCount
- In case a limit of pages per page is defined, the
:paginationCount
reflects the number of pages the pagelist will be distributed over.
Examples
The runtime variable :pagelistCount
reflects the number of pages in the current pagelist. It can be used to quickly test whether a pagelist is empty or to create counting badges.
<@ newPagelist {
type: 'children',
excludeHidden: false
} @>
<h2>@{ :pagelistCount } Pages</h2>
A pagelist can be subdivided into multiple segments with a maximum number of items per page to easily create pagination navigations. Therefore the runtime variable :paginationCount
can be used to get the number of parts of the pagelist depending on the pagelist limit per page.
<@ newPagelist {
limit: 10,
page: @{ ?page | def(1) }
} @>
<@ for 1 to @{ :paginationCount } @>
<a href="?<@ queryStringMerge { page: @{ :i } } @>">@{ :i }</a>
<@ end @>