Users preview for page-table plugin

Hello Kirby communit,

This question is probably better answerd by @sylvainjule if you have a minute :slight_smile:

Is it possible to show user name or email instead of ID inside pagetable.

Right now I have this as a result, wish makes kind of sense since it’s what is stored in the content file


Maybe I’m missing something like :

       width: 1/6
       label: Auteurs
       text: '{{ page.auteur.toUser }}' // toUser and something like "mail" or "name"
       type: users

I was expecting something like in this screencapture from another kirby user:

Thanks in advance,

All my best and good health to all.

The toUser method returns a User object. So, in order to output the name for example, you’d have to call '{{ }}'

The issue here, is what’d happen if there is no user found, you’d call the name method on null.

Better wrap this in a custom Field method:

Kirby::plugin('my/field-methods', [
    'fieldMethods' => [
        'toUsername' => function($field) {
            $user = $field->toUser();
            return $user ? $user->name() : '';

And then call '{{ page.auteur.toUsername }}'

As for the preview on the screenshot above, you’d have to recreate it in the field methods because I haven’t found time to add the field previews in pagetable.

1 Like

Merci Sylvain ,

Thank for the input on using a field method I’ll do it that way.

All my best !