Hi all - I have a controller for my projects page which allows me to filter projects by location. Projects controller below:
<?php
return function($page) {
$locationFilter = param('location');
$sectorFilter = param('sector');
$projects = $page('projects')->children()->listed();
$location = $projects->pluck('location', ',', true);
$sector = $projects->pluck('sector', ',', true);
// filter conditionally
$projects = $projects
->when($locationFilter, fn($locationFilter) => $this->filterBy('location', $locationFilter, ','))
->when($sectorFilter, fn($sectorFilter) => $this->filterBy('sector', $sectorFilter, ','));
return [
'locationFilter' => $locationFilter,
'sectorFilter' => $sectorFilter,
'projects' => $projects->paginate(99),
'location' => $location,
'sector' => $sector,
];
};
I decided I’d like to extend this feature beyond just the projects page and include a list of all the locations in the footer page for improved seo.
So I changed the projects to be the standard site controller, but if I change
$projects = $page->children()->listed();
to
$projects = $page('projects')->children()->listed();
I get the following error:
Object of type Kirby\Cms\Page is not callable
How can I call the children of a specific page in this scenario?
Thanks so much