Display a list of pages


I’m building a quick Client/Projects management platform (for internal use only) using Kirby 3.6.6.

I created 2 types of pages:

  • clients and client
  • projects and project

In project.yml, I have a client field:

 18               gen_client:
 19                 label: Client
 20                 type: multiselect
 21                 max: 1
 22                 options: query
 23                 query: site.pages.template("clients").children.template("client")
 24                 required: true

In client.yml, I’m trying to list all projects linked to the currently displayed client, and I’m not having any success.

I know that I could do this easily with subpages, but I would lose the ability to list all projects (I don’t want to have to go into a client to edit/create/find a project).

Any suggestions?

Hey there, welcome!

Using a pages section, you mean? Currently, you cannot use a query in a pages section, unless you use a plugin: GitHub - rasteiner/k3-pagesdisplay-section: K3 plugin: display any page list in a section. Any parent, many parents, filtered, don't care.

Thanks for the plugin suggestion, it’s exactly what I’m trying to do.

Now I need a little help with the Query Language…

I have this:

  7     sections:
  8       projects:
  9         type: pagesdisplay
 10         headline: Projects
 11         query: site.pages.template('projects').children.template('project')
 12         controls: false

It works, but it displays ALL projects.
I tried this, without success:

11 query: site.pages.template('projects').children.template('project').filterBy(page.slug, 'in', 'gen_client')

I’m getting an error about ‘gen_client’ not being an array… how can I reference the children’s gen_client field in the query? gen_client is a multiselect, so it must be an array, and I’m looking for my value in that field.

You will need a model for this, because you have to filter the projects with a callback by whether the given field converted to pages contains the current field. This cannot be done with query language.

Any way I can do a simple string comparison using a query?
I switched my multiselect to a select, the value gets stored like this in projects:

Gen-client: clients/akaris

I guess page.slug is just ‘akaris’ (not clients/akaris).

If it’s only a simple select now, you can do it like this

site.pages.template('projects').children.template('project').filterBy(gen_client, '==', page.id)