Fetch title and url of selected page in a structure

Hello, it seems it a too long time I did not play with Kirby…

I try to fetch the title and the url of a page selected in a structure. I can have or the title, or the url but both not…
For the moment blueprint and template lokk that this

test Blueprint:

selectproject:
  label: select project
  type: structure
  style: table
  entry: 
    - projectlink
  fields:
    projectlink:
      label: project
      type: select
      options: query
      query:
        page: projects
        fetch: children          
        text: '{{title}}' 
        value: '{{url}}'
    projectdesc:
      label: description
      type: textarea

test template:

  <?php foreach($page->selectproject()->toStructure() as $item): ?>
  <?= $item->projectdesc() ?>
  <br>
  <a href="<?= url($item->projectlink()) ?>"> ?Project title? </a>

  <?php endforeach ?>

There are a lot of topic about this, but I was not able to find a solution.

Thank you for your advices.

First of all, I would not store the URL but the URI.

Then you can get the page object like this:

<?php
if($p = $item->projectlink()->toPage()):
 echo $p->title();
endif;
2 Likes

I keep this post in my bookmark, thanks again Texnixe!