Hi there, working with good old Kirby 2.
Filtering images from an image field (images plugin) with a project.php
controller for my project.php
template, and have no issues so far, also have a different installation where everything is working as expected.
However, in one case, I’m having a strange issue when $galleryType == 'grid'
. Here I’m querying the images from the field but getting Undefined variable: uri
.
What is strange is that it works if I manually set the uri in:
$val = implode(", ", page($uri)->galleryimages()->yaml());
to projects/nosted
in this case:
$val = implode(", ", page('projects/nosted')->galleryimages()->yaml());
Running Kirby 2.5.12 on PHP 7.2.
<?php
return function($site, $pages, $page) {
// Gallery Field Image Filtering
$uri = $page->uri();
$galleryType = $page->gallerytype();
if($galleryType == 'alternating') {
$images = $page->galleryimages()->yaml();
} elseif($galleryType == 'grid') {
$images = $page->images()->filter(function($image) {
$val = implode(", ", page($uri)->galleryimages()->yaml());
$filenames = explode(", ", $val);
return in_array($image->filename(), $filenames);
});
}
return compact(
'galleryType',
'images'
);
};
Any thoughts on what might be the issue?
Best, Oliver