Skip to content

Kirby 6.0.0

Pagelist

List and edit subpages

Field options

Name Type Default Description
batch bool false Show/hide the batch select interface
blueprints arrayorstring null Filters the list by one or more blueprints, which are also the options for new pages. With except, all other blueprints are listed and offered instead.
columns array no default value Columns config for layout: table. false hides a column, a string sets its label.
create arrayorstringorbool null Blueprints that may be added or false to disable page creation
default mixed null Default value for the field, which will be used when a page/file/user is created
empty arrayorstring null Sets the text for the empty state box
flip bool false If true, the order of the entries is reversed
help arrayorstring null Optional help text below the field
image arrayorstringorfalse [] Image options for each entry, a query string for the preview image or false to disable previews
info arrayorstring null Info text shown next to or below the main text of each entry
label arrayorstring no default value The field label can be set as string or associative array with translations
layout string 'list' Switch the layout of the items. Available layouts: list, cardlets, cards and table
limit int 20 The number of entries that will be displayed at once. Afterwards pagination kicks in.
max int null Sets the maximum number of allowed items in the field
min int null Sets the minimum number of required entries
page int null Sets the default page for the pagination
parent string null Query for the parent model that holds the entries
query string null Filters the entries by a query. Sorting will be disabled
search bool false Enables/disables the search
size string 'auto' Size for layout: cards. Available sizes: auto, tiny, small, medium, large, huge, full
sortBy string null Sorts the entries by the given field and order (i.e. title desc) Drag & drop is disabled in this case
sortable bool true If true, entries are sortable via drag & drop
status string 'all' Filters the pages by their status
templatesIgnore arrayorstring [] Alias for the except list of the blueprints option
text arrayorstring '{{ model.title }}' Setup for the main text of each entry
translate bool true Should the field be translatable?
when array null Conditions when the field will be shown
width string '1/1' The width of the field in the field grid. Available widths: 1/1, 1/2, 1/3, 1/4, 2/3, 3/4

What is a pagelist field?

A pagelist field lists the children of a given parent or a set of pages defined by a query. pagelist fields also let you do the following operations (if not forbidden or impossible because of other settings):

  • create a new page
  • delete a page
  • change the status of a page
  • move a page
  • duplicate a page
  • change the page slug
  • change the page template
  • change the order number

Example

title: Shop

fields:

  drafts:
    label: Drafts
    type: pagelist
    status: draft
    blueprints: product

  published:
    label: Published Products
    type: pagelist
    status: listed
    blueprints: product
Screencast

A closer look at `pagelist` fields

Show subpages as cards or list, add additional info for each page, control the card design – there are hardly any limits.

This video is loaded from YouTube servers with your consent. Read more…

A pagelist stores nothing in the content file. It displays the pages that already exist, so there is no value to fetch from it in your templates.

Shortcuts

For simple lists that are only used once per blueprint, you can use shortcuts. In its most basic form, a pagelist field consists of the field type as name, and true as its value.

fields:

  pagelist: true

This will add a pagelist field with all default properties.

These shortcuts can be extended with other field properties as needed, for example:

fields:

  pagelist:
    label: Main Pages
    status: all

Keep in mind that the same field name can only be used once per blueprint.

Label

The label will be displayed above the pagelist field. You can pass a simple label as a string or you can provide translations for multiple languages, if you have an international editing team.

Single language

label: Articles

Multiple languages

label:
  en: Articles
  de: Artikel
  es: Artículos

Placeholders

You can inject information from the current page into the label with template placeholders using our query language.

label: "Articles for {{ page.title }}"

Layout

The pages can either be displayed as a simple list or as cards with preview images. The list view is the default view.

List layout (default)

The list layout is perfect for more text-heavy pages, like articles, link lists, simple pages, etc.

layout: list

Cards layout

The card layout is great for media-heavy pages, like galleries, products, projects, etc.

layout: cards

Cardlets layout

The cardlets layout is great for nice visual previews of files, while your text content is still representend decently.

layout: cardlets

Table layout

The table layout has the highest information density. Columns can be fully customized and make it perfect if you need to show multiple values at once for better overview and scannability.

layout: table

The table layout will show the preview image together with a title and info column based on your text and info settings. You can switch off those automatic columns with image: false, text: false and info: false if you want to introduce your own columns.

Columns

Custom table columns can be defined with the columns option.

layout: table
columns:
  subheading: true
  date: true

Each column can be customized with additional settings:

Label
layout: table
columns:
  subheading:
    label: Subheading
Translated label
layout: table
columns:
  subheading:
    label:
      en: Subheading
      de: Unterüberschrift
Alignment

Text alignment can be left (default), center or right.

layout: table
columns:
  subheading:
    label: Subheading
    align: right
Width

The column width can be set with the width property. You can use the usual fractions:

layout: table
columns:
  info: false
  subheading:
    label: Subheading
    width: 1/3
  title:
    width: 1/3
  date:
    width: 1/6
  tags:
    width: 1/6
Value

By default, the table cells contain the field value matching the column name. You can customize the value with a string template.

layout: table
columns:
  date:
    label: Date
    value: "on {{ page.date.toDate('d.m.Y') }}"
    type: text

If the page actually has a date field of type date, Kirby will automatically use the date field preview component for this column. However, this will clash with your custom value. This is why we also set type: text.

HTML

Values are converted to safe HTML by default. This is the most secure way to handle content in your Panel. If you know what you are doing and you want to render HTML in a table cell, you can use the html option to stop HTML from being auto-encoded.

layout: table
columns:
  html:
    label: HTML
    type: html
    value: "{{ page.someSafeHTML }}"
Mobile

Set the mobile option to true for a column to be visible in the mobile view.

layout: table
columns:
  subheading:
    label: Subheading
    mobile: true
Type

To display different content, you can use column types to improve the preview of your data, e.g. text, url, tags.

Check out the field previews in our Lab to get an overview of the various previews that can be used as column types.

Customizing default columns
layout: table
info: "{{ page.slug }}"
columns:
  title:
    label: Custom title label
  info:
    label: Custom slug label
    width: 10rem

Page information

You can fine-tune the display text and additional information for every page in the list with the text and info options.

text

By default the page title is shown in the list for every page. You can use our template syntax with query language to fetch any information from the page and display that instead of the title.

text: " {{ page.title.upper }}"

info

If you want to display additional information for each page, like a date, year, category or any other field value, you can use the template syntax with query language in the info option.

info: " {{ page.date.toDate('Y-m-d') }}"

Preview images

The (preview) image for each item in the list is by default what is configured in the respective page blueprint. However, you can customize these further for your field with the same options as in the page blueprint:

type: pagelist
image:
  query: page.cover.toFile
  icon: 📝
  back: blue-700
  color: white
  cover: true

Empty state

With the empty option you can define the message which is displayed when no pages are listed in the field.

empty: No articles yet

Filtering pages

Parent

By default, the current page is being used as the parent to find children for the list. With this option, any page on your site can be the parent of the field

parent: site.find("blog")

query

The pagelist field supports a query option to filter the pages that are shown in a field using our query string syntax. Manual sorting will be disabled for fields with a query.

videoPosts:
  type: pagelist
  label: Video posts
  query: page.childrenAndDrafts.filterBy('category', 'video')
  blueprints: article

otherPosts:
  type: pagelist
  label: Other posts
  query: page.childrenAndDrafts.filterBy('category', '!=', 'video')
  blueprints: article

The query option cannot only be used in the context of a single page, but you can also query the complete site index if that makes sense, for example in site.yml:

siteIndex:
  type: pagelist
  query: site.index(true).notIn(['error'])
  create: default

Status

You can filter the list of pages by their status. The available status values are

Status Description
draft Only drafts will be shown
listed Only listed pages (with a sorting number) will be shown
unlisted Only unlisted pages (without a sorting number) will be shown
published Listed and unlisted pages will be shown
all (default) Drafts, listed and unlisted pages will be shown
status: draft

Note that an "Add" button for new pages will only be available if you use either status: draft or status: all.

Blueprints

The blueprints option filters the list by page blueprint. The same blueprints are available when adding new pages to the field.

Single blueprint

blueprints: article

Multiple blueprints

blueprints:
  - project
  - article

All blueprints except some

blueprints:
  except:
    - error
    - home

The list then shows pages with any other blueprint, and new pages can be added with any other blueprint.

In Kirby 5, this option was called templates (or template), and templatesIgnore excluded blueprints. The old names still work.

If only one blueprint is available when adding a new page, the template select will be hidden in the dialog (except when the debug option is active).

"Add" button

Editors can add new pages to the field with the "Add" button in the top right corner.

status: all status: draft status: listed status: unlisted
+ Add + Add

The add button will only show up if the status option is set to draft or all

Why?

New pages are always added as draft. If the "Add" button showed up in a field that only shows listed or unlisted pages, the "Add" button would lead to a confusing interaction for editors, as the new page would not show up in the field.

Batch delete pages

When managing many pages, it can be tedious to delete them one by one. Adding batch: true, allows you to select multiple pages and delete them at once.

notes:
  type: pagelist
  batch: true

Sorting

sortBy

You can sort the list of pages by one or more fields/properties in descending or ascending order.

sortBy: date desc
sortBy: date desc title asc
sortBy: status desc year desc

You can pass PHP sorting type flags, for example to make sorting work with special language specific characters.

sortBy: title SORT_LOCALE_STRING
sortBy: title asc SORT_LOCALE_STRING

The sortBy option only has an effect on the display order inside this field in the Panel. Because all pages will always be sorted by the field/property you defined, manual drag and drop sorting inside the field is disabled.

However each page can still have its own sorting number, which can be controlled via the page status dialog. If you don't need or want the custom sorting numbers, you need to disable them with the num option of the child page blueprint.

flip

Use the flip option to enable/disable reverse sorting (default is false):

sortBy: title
flip: true

sortable

You can switch off manual sorting entirely with the sortable option.

sortable: false

Limits

limit

The limit property sets how many pages will be shown per page. If there are more entries in the field, the pagination navigation will be shown at the bottom of the field.

limit: 20

max

You can define a maximum number of pages, that will be allowed in this field. After the maximum is reached, the add button will be hidden and no more pages can be added.

max: 10

min

You can also define the minimum number of pages, that need to be added in order to make the page valid.

min: 2

Conditional display

Like any other field, a list can be shown or hidden based on the value of another field. Set the condition with the when option, using a field name as the key and the value it has to have.

In the following example, each field is shown based on a different value of the postType field:

fields:
  postType:
    type: select
    options:
      - Gallery
      - Image
      - Text
  gallery:
    type: filelist
    template: gallery-image
    layout: cards
    size: tiny
    when:
      postType: Gallery
  image:
    type: filelist
    template: single-image
    max: 1
    layout: cards
    when:
      postType: Image
  text:
    type: textarea
    when:
      postType: Text
  tags:
    type: tags
    when:
      postType: Text

See conditional fields for the full set of rules.

Search is disabled by default. You can use the search option to enable it.

fields:
  drafts:
    type: pagelist
    search: true
Screencast

Build a bookmark tool

An example how to build a nice overview with the table layout in the `pagelist` field showing all relevant columns.

This video is loaded from YouTube servers with your consent. Read more…