Hello Community,
I want to create a user profile page with all projects the user has organised. The page-type “project” has a user field called “organiser”.
My idea was to use the filterBy-Method to filter the projects according to the current (logged in) user and display the projects in a list with a foreach-loop.
Can you tell me what I need to change to make it work?
<?php
$user = $kirby->user();
$myprojects = page('projects')->children()->filterBy('organiser', $user);
?>
<main class="main">
<h1><?= $page->title() ?></h1>
<h2> Meine Projekte </h2>
<ul>
<?php
foreach($myprojects as $myproject) :?>
<li>
<a href="<?= $myproject->url() ?>">
<figure>
<?= $myproject->image()->crop(400)?>
<figcaption><?= $myproject->title() ?></figcaption>
</figure>
</a>
</li>
<?php endforeach ?>
</ul>