Query pages related to a user within a page section with parent set to a different page

Hi dear community!

I’m currently working on a website where users (with ‘author’ role) can be assigned as authors of pages (with ‘article’ template). In an article.txt file then I can have these lines:

Authors:

- 'user://gxkWHigQ'
- 'user://ns3burFw'

I need in the author blueprint to list all articles they have been assigned to. This is what I’ve written:

articles:
  label: Articles
  type: pages
  create: false
  parent: page('page://a7yn5pwzj9er8wpz') -> The Blog page
  query: page.children.filterBy('authors', '*=', {{ user.uuid }})

When manually replacing {{ user.uuid }} by a real user uuid like 'user://ns3burFw' it works perfectly… however as the parent is a different page than the user, it seems I cannot pass there user.uuid.

Would you have any clue of how I can do that please?

I’d suggest writing a custom user method for this. In my opinion that’s also more readable in the blueprint than some complex filtering logic. Something like user.articles.

1 Like

Thanks Thomas. That’s a better approach indeed :wink: