toPage from string


In the panel: on the home page, I have a pages field on which a panel user can select subpages from another page (a project from a projects page). I’d like to access the fields of the selected subpage (title, image urls etc.)

Unfortunately, it tells me that the output of the pages field is a string, so I can’t really access the fields of the subpages. I searched the reference and tried toPage() to no avail. Is there another function similar to toPage()?

  $slideshowitems = $page->slideshowprojekte();
  foreach($slideshowitems as $slideshowitem):

      <?= $slideshowitem->toPage()->title() ?>

<?php endforeach ?>

The page structure is:
• something
• something
• projects –> project 1, project 1, project 1
• something
• else

Thanks for any input!

It kind of works if I change the top to toPages(). But only the title() works, but not if I want to access the images of the project subpages. Like <?=$project->thumbnail()->url(); ?>. The url output is (unknown).

  $slideshowitems = $page->slideshowprojekte()->toPages();
  foreach($slideshowitems as $slideshowitem):

Ok, I know why the images don’t work. Despite them being displayed in the panel, they’re not in the according project.en.txt file. How come?

The blueprint is:

  type: files
  headline: Thumbnail
  template: thumbnail-image
  max: 1

Because a section doesn’t store anything in your content files. You can, however, fetch the image by template name.

1 Like

This works.