Pages table layout - fallback column content

Hi,
I am having a play with the new pages “table” layout in 3.7, and very much enjoying it.
I am trying to display some fallback content, if the value query comes up empty. This is what I have so far:


replies:
  type: pages
  template: community-reply
  layout: table
  image: false
  sortBy: postDate asc
  columns:
    postDate:
    label: Posted
    type: date
    display: DD.MM.YYYY - HH:MM
  author:
    label: Author
    value: "{{ page.author.toUser.school.toPage.title.or('Admin') }}"

If the author has a school associated with it, then that displays perfectly. However if they don’t the column is blank, and I would like it to read “Admin” (only admin users don’t have a school).

Is this possible?
Thanks!

The problem is that if school is empty, toPage() will return null, and hence you don’t even get to title without error, let alone reach the or bit.

I think you better create a custom page method (or model method), that does some valuation of values inside, then return the fallback from there.

Thanks for the steer @texnixe that has done the trick.

For future reference this is how I got the result I was after:


<?php

class CommunityReplyPage extends Page {
    public function authorIdent() {
        $role = $this->author()->toUser()->role();
        if($role == 'participant'):
            return $this->author()->toUser()->school()->toPage()->title();
        else:
            return 'Admin';
        endif;
      }
}