If I understand you right, you have a custom /users page with the users as children of that page, so it’s the same procedure as for blog post, fetch the children of that page and display their information:
<?php foreach(page('users')->children() as $profile()) {
//do stuff
}
Or do you mean panel users? Then you can get them like this:
Hi @texnixe
Thanks for your reply.
At the moment, I have no special ‘object’ on the site called users, appart from, well, (panel) users…
And I’d rather not duplicate the information (create a user object). Is there a way to list people that have an account on the site and display their name and avatar?
Following your advice, I managed to make have a list of my (panel) users on a /users page, but I can’t figure out how to have a ‘profile’ page for each of them (without duplicating the content)…
Thanks
The second option ($site->users()) I posted above is then what you want. I was just irritated, because you mentioned a users folder with subfolders which does not exist in Kirby. You can find all about the $users/$user object in the cheatsheet.
Yes, I know the users folders don’t exist, but I don’t really understand how to generate a page like mysite.com/users/john-doe without duplicating the content.
At the moment, I have created a ‘users’ folder with a users.php template that lists all the users (using $site->users()). But now, how can each name link to a dedicated ‘profile’ page?
I can kind of see how I could do it by passing a parameter in the url like mysite.com/users/name:john-doe but it’s not very clean, is it?
Well, first of all, if you don’t want to create children of /users, you do not need the /users folder, you can use a route instead that calls the template.
And you can also use routes to create the dedicated profile pages.