User Blueprints in Panel: Can I filter a pages section based on the user?

Hello!
Long time reader, first time poster here :slight_smile:

I have a Kirby setup with multiple users.

In one of my page templates, I added a “pageCreator” field which allows me to pick one of my users as the creator of the page - by default, whoever is logged into Kirby when the page is created:

fields:
  pageCreator:
    type: users
    label: This is the page creator
    multiple: false
    default: true

This part seems to work well, I am able to see which user created each page, the user IDs are populated in the txt files, in the following format:
Pagecreator: - user://Ckh6rou8


Now I am trying to create Panel Blueprints for my Kirby Users. For each user, I want to include a table that lists the pages that were created by that user.

Here is what I have so far:

sections:
  info:
    type: info
    text: "{{ user }}"

  createdPages:
    type: pages
    parent: site
    layout: table
    query: site.index.filterBy("pageCreator",{{ user }})

The info section I’m starting with was added for a little debugging - and it successfully displays the ID for the user I am currently looking at.

The table, which should list pages filtered by that same user ID, does not work.

  • As a test, using query: site.index.filterBy("pageCreator","") actually works, providing a list of dummy pages that have no creator.
  • As another test, manually typing in the User ID works, but only if I switch filtering methods - and shows pages created by the relevant user. As in: query: site.index.filterBy("pageCreator","*=","THE USER ID FROM ABOVE")

No matter what I do, I can’t seem to get the user I am currently looking at into the query - I tried "{{user}}", user, and a variety of other ideas - anything I try always returns an empty list.

I also tried reading the Filtering Collections page in the Cookbook, but could not figure out if the method shown there can be done from within yml files somehow.

Can you please help out?

Thank you!

        query: site.index.filterBy("pageCreator", user.uuid, '-')

It’s a bit of a hack, but you cannot use a callback here to do it properly, unless you create a custom method. The third argument takes the separator. For a field with a comma separated list, you would pass in a comma. The users field (like the pages or files fields) stores its values as yaml list, starting with a dash.

Thank you for the quick response!!

Say I have two users: one is an Admin (User ID is 1111) and the other is an Author (User ID is 2222). The Admin is logged into Kirby and looking at the Author based on the User Blueprint.

Where I have text: "{{ user }}" above the query, as my attempt to debug, I actually do get the UUID for the user I am looking at (2222). However, in the query below it seems to always get the UUID of the user that is currently logged into Kirby (in this case, 1111).

I think I am seeing the same when using the query you suggested… is it even possible to see all pages created by “2222” even though “1111” is logged in?

Thanks again!
Omer