Building user profile pages in Kirby 3

Thanks @texnixe

I had tried something like that.

In any case when I do a var_dump the info is better!

This is what I get when I do:

          array(3) {
  [0]=>
  array(4) {
    ["id"]=>
    string(1) "0"
    ["social_events_date"]=>
    int(2021)
    ["social_events_description"]=>
    string(73) "Après avoir roulé depuis 2017 seul, je découvre le club."
    ["social_events_listing2"]=>
    array(1) {
      [0]=>
      array(5) {
        ["social_events_listing2_title"]=>
        string(21) "Adhésion au club ACM"
        ["social_events_listing2_date"]=>
        string(10) "2021-06-11"
        ["social_events_listing2_city"]=>
        string(26) "City"
        ["social_events_listing2_text"]=>
        string(0) ""
        ["social_events_listing2_related"]=>
        array(0) {
        }
      }
    }
  }
  [1]=>
.... and more
}

In my template I have the foreach loop but when I do for example $item->social_events_date()

          <?php 
              $items = $page->social_events_listing();
              foreach ($items as $item): 
          ?>

Error
Call to a member function social_events_date() on array

This is missing the toStructure field method!

Exactly !

Thanks a lot

$items = $page->social_events_listing()->toStructure()->flip();

Getting back to the model.

I recovered the slug to be able to make a link in my pages of the members.

I would like to know if my url is well optimized?

<a href="membres/<?= Str::slug($user->firstname() ." ". $user->namefamily()) ?>"><?= $user->firstname() ?> <?= $user->namefamily() ?></a></div>

the url of my page is of this type:
http://localhost/website.fr/starterkit-master/club/membres/mickael-durand

other solution:

<a href="<?= $site->url() ?>/club/membres/<?= Str::slug($user->firstname() ." ". $user->namefamily()) ?>"><?= $user->firstname() ?> <?= $user->namefamily() ?></a></div>

Can we do better to avoid having to write /club/members ?

I’m missing a bit of context here. Why do you want to create these links manually? All the subpage have a normal URL now.

foreach (page('membres')->children() as $member) {
   echo $member->url();
}

Or if you want to fetch a particular memberpage

if ($member = page('membres')->children()->findBy('slug', 'john-doe')) {
  echo $member->url();
}

Don’t know if that answers your question, otherwise maybe rephrase your question and provide more context. Thanks!