Hello
I have a pretty simple structure:
A page object that has a files field holding images of team members:
title: Team
icon: 👥
sections:
content:
type: fields
fields:
teammembers:
label: Team Mietglieder
type: files
uploads: teammember
layout: cards
info: "{{ file.fullname }}"
I am utilizing file blueprints to store name and description of the team members in the corresponding files:
title:
en: Teammember
de: Team Mietglied
accept: image/*
fields:
fullname:
label: name
type: text
description:
type: text
All well and good so far but now I want to access said images and their data on a page to render them:
<?php foreach (page('Team')->teammembers()->first()->toArray() as $member) : ?>
<div class="col-lg-4 col-md-6 col-sm-12 text-center teamcard">
<div class="teamcard-bg">
<img class="mb-3" src="<?= $member->url() ?>" alt="">
<h4 class="mb-2"><?= $member->fullname() ?></h4>
<span><?= $member->description() ?></span>
</div>
</div>
<?php endforeach; ?>
as far as i understand the code goes like this:
teammembers() returns an array of all fields that are named “teammembers”
thats why I am calling first() on it to just receive the only element that exists.
Now first() has returned me a php object of type “field”.
Since the field I have specified in the blueprint is of type “files” and holds multiple images I assume I need to call the toArray() function.
But this only returns me strings of the files:
“- file://r1CfpSVeeG59zv25 - file://kxnLWmihYqR9iHS8 - file://q7bmfN6iBFRMqYB4 - file://ws8yIkz26ZHg9diq - file://bdpPGgkdDG3k9e3Y - file://ozjwD29Gegn59h38”
it even has the dashes and file:// just like it is stored in the content file.
I havent found a way to convert these strings into the actual images and I feel like this is probably the wrong approach I am taking here.
If I instead do page(‘Team’)->teammembers()->images() and iterate over these it works without a problem but it doesnt sort the images in the way I manually dragged them in the “team” page panel.
And calling “images()” only seems like a band-aid fix since if I were to retrieve any other field or data Id face the same issues as above again.
What am I misunderstanding?
I appreciate any and all help