Hello everyone,
My issue is the following, I’m trying to loop through all the média of my sections, the issue is some are files but some are field values vimeo links, and I want them to go along that same loop (in other words I’d like to avoid creating a foreach at the end of my document for the vimeo links)
Is that possible ?
My code looks like that :
<div class="portfolio slide" id="sections">
<?php foreach ($pages->find('projets')->children()->listed() as $project): ?>
<?php
$section = $project->children()->listed();
$mobileSection = $section->files()->filterBy('classDesk', '!=', 'only-desk' );
$sortedMobileFiles = $mobileSection->sortBy('name', 'asc');
$vimeoLink = $section->vimeo();
foreach ($sortedMobileFiles as $media):?>
<div class="visuels">
<?php if ($media->type() == 'image'): ?>
<div class="images-projets <?= $media->classDesk() ?> ">
<img style="object-fit: <?= $media->Fitstyle() ?>;"
alt="<?= $media->alt() ?>"
data-lazy="<?= $media->url() ?>"
width="<?= $media->width() ?>"
height="<?= $media->height() ?>"
>
</div>
<?php elseif ($media->type() == 'video'): ?>
<div class="images-projets">
<video class="gif" loop="true" autoplay="true" muted="true" src="<?= $media->url() ?>" alt="<?= $media->alt() ?>" type="<?= $media->mime() ?>" ></video>
</div>
<?php endif; ?>
</div>
I tried adding
<?php if ($section->vimeo()->isNotEmpty()): ?>
<div class="images-projets <?= $section->vimeoClassDesk() ?>">
<iframe src="https://player.vimeo.com/video/<?= $section->vimeo()?>?dnt=1&background=1&" style="width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen=""></iframe>
</div>
<?php endif; ?>
but obviously as it is not a file it calls me on null
I look through the forum but i’m a bit confused between collections and sorted function…
Thanks in advance for your time
J