Page from Select Field

Looks like Saturdays and Sundays are the perfect time to spot problems in my Kirby sites :sweat_smile:

I have structured field in my home.yml blueprint in which I have a select field that pulls all the pages with a project template.

Looks like this

slideproject:
    label  : Projects
    type   : select
    options: query
    query  :
        fetch    : pages
        template : project

The select works as expected and I can sepickect the projects I need to display without troubles.
Now in my home.php template I do the following:

<?php
if ($slides = $page->slides()->toStructure()) :
    foreach ($slides as $slide) :
        
        $project = $slide->slideProject();

    endforeach
endif;
?>

Up until this point everything works correctly and I get the correct uri if I try to echo the $project variable.
My problem is, no matter what I do, I can’t get the page object using the uri

None of these work

page($project)->title();
$project->toPage()->title();

The only option that seems to work is

$site->index()->findBy('uid' , $project)->title()

Is this normal or am I missing something?
The site is multilang.

If you change your blueprint like this, i.e. using the value option

slides:
    label  : Projects
    type   : select
    options: query
    query:
      fetch: pages
      template : project
      value: '{{uri}}'

the URI will be saved to file, not only the UID like in your example.

Then you can get the page like this:

<?php
  if ($slides = $page->slides()->toStructure()) :
      foreach ($slides as $slide) :

          $project = $slide->slideProject();
          echo page($project)->title();

      endforeach;
  endif;
?>
1 Like

So to answer to my question, yes, I was missing something :grin:
Thanks @texnixe