Link and name page in template

Hello,

I have a chanson.yml. I can select a or multiple personne.yml

        sections:
          credits:
            type: fields
            fields:
              auteur:
                type: pages
                multiple: true
                query: site.find('personnes')
                image:
                  back: black
                width: 1/3
                empty: Aucune entrée
              compositeur:
                type: pages
                multiple: true
                query: site.find('personnes')
                image:
                  back: black
                width: 1/3
                empty: Aucune entrée
              adaptateur:
                type: pages
                multiple: true
                query: site.find('personnes')
                image:
                  back: black
                width: 1/3
                empty: Aucune entrée
              editeur:
                label:
                  fr: Editeur(s)
                  en: Editor(s)
                type: pages
                multiple: true
                query: site.find('editeurs')
                image:
                  back: black
                width: 1/3
                empty: Aucune entrée

And in a template of chanson.php, i would like show a name and link page of a or multiple personne(s).

<ul>
<li><a href="http://localhost/cms/kirby/rslt/personnes/erick-benzi">Erick Benzi</a></i> 
<li><a href="http://localhost/cms/kirby/rslt/personnes/jacques-veneruso">Jacques Veneruso</a></li>
</ul>

What code should I put in to get it?

See docs how to render a pages field in your templates: Pages | Kirby CMS

I already tried before posting this message.

<ul>
  <?php if ($auteur = $page->auteur()->toPage()): ?>
        <li>Auteur : <a href="<?= $auteur->url() ?>"><?= $auteur->title()->escape() ?></a><li>
  <?php endif ?>

This only returns me correct result for one item while i have selected two personnes.
Maybe i have a name (Erick Benzi) with the good link (http://localhost/cms/kirby/rslt/personnes/erick-benzi)

I tried something else:

    <?php if (!empty($auteurs)): ?>
    <ul class="note-tags">
      <?php foreach ($auteurs as $auteur): ?>
      <li>
        <a href="<?= $page->parent()->url(['params' => ['auteur' => $auteur]]) ?>"><?= esc($auteur) ?></a>
      </li>
      <?php endforeach ?>
    </ul>
    <?php endif ?>

and i have a controller:

<?php
return function ($page) {
    return [
        'tags' => $page->tags()->split(','),
        'auteurs' => $page->auteur()->split(','),
        'compositeurs' => $page->compositeur()->split(','),
        'editeurs' => $page->editeur()->split(','),
    ];
};

This gives:

- page://FWqz2sEJZ0esSppx - page://zkwiZ2Mf7IlBqEk1](http://localhost/cms/kirby/rslt/chansons/auteur:-%20page%3A%2F%2FFWqz2sEJZ0esSppx%0A-%20page%3A%2F%2FzkwiZ2Mf7IlBqEk1)

Please see the link above again, there are two options: single page and multiple pages.

I ended up finding it on my own.

<?php
$auteurs = $page->auteur()->toPages();
if ($auteurs->count() > 0):
?>
  <ul><b>Auteurs :</b>
    <?php foreach($auteurs as $auteur): ?>
    <li>
      <a href="<?= $auteur->url() ?>">
        <?= $auteur->title() ?>
      </a>
    </li>
    <?php endforeach ?>
  </ul>
<?php endif ?>