In a user blueprint I would like to get the user id from the user I have selected in the user list.
I want to use it in a query: (see userId_selected below)
headline: Proposals as author
query: site.index.filterBy('template', 'proposal').filterBy( 'proposalAuthorId', **userId_selected** )
Is that possible?
My goal: In a user blueprint, I try to display all the pages which belong to this user. These pages have a proposalAuthorId field which store the user id.
This should work:
query: site.index.filterBy('template', 'proposal').filterBy( 'proposalAuthorId', kirby.user.id)
Edited, in a section, you have to use kirby.user
I’ve already tried this synthax but Kirby return this error:
The section "candidatProposalsParticipants" could not be loaded: Access to non-existing property user on array
See edit above.
What I posted originally, works in a field.
This code return the current logged in user not the user I have selected.
If I logged in as admin and select “Sonja” user in the user list, I get the page which belong to me (the logged in user) not Sonja’s pages.
I am write?
Oh, yes, true. I’m afraid it doesn’t work then with a pages section because the current context of these section is the page and not the user. The first version I posted before the edit worked with a pages field, but not with the section.
What’s the purpose of this section anyway?
I just tried
page.id which seems to work? Although it seems weird.
query: site.index.filterBy('template', 'proposal').filterBy( 'proposalAuthorId', page.id )
Ok, maybe I can use instead a user models to define a new method which I would be able to call in a info field in my user blueprint.
I’m going to try this !
Yes I confirm, it’s working