Hello everybody,
I am trying to cycle through all my »projects« and for those projects that have an Image with a name that contains poster
I want to do something. And for those that don’t have such an image I want to do something else.
This is what I came up with by browsing the forum (I have no understanding of php).
But for all projects the function returns Y
even though some of the pages don’t contain a file with the filename containing poster
.
What am I doing wrong? Any suggestions?
<?php foreach(page('projects')->children()->visible() as $project): ?>
<?php if ($image = $project->images()->filterBy('filename', '*=', 'poster')): ?>
<p>YES</p>
<?php else: ?>
<p>NO</p>
<?php endif ?>
<?php endforeach ?>