I am quite new with Kirby. I am trying to use “Page relations” but i am stuck with some functionality.
Let say I have a page called actors with all the actors as subpages and I have a page Films with all the films as subpages. To make relations I create a field “pages” on the films page. That way I can select which actors participate on the film and I can select more than one. On the film page template I can so all the name of the actors and link to their pages, no problem.
But it doesn’t find the correct relation when there is more than one actor. It is logic as the “actor field” is not equal to the page id it contains more than one.
How could I filter it? Should I use another kind of field?
The *= (contains) method might not be the best approach because it can lead to false results. Using filter($callback) is the right approach, but the above snippet is missing the $page variable and should be:
$films = $pages->find('films')->children()->filter(function($film) use ($page) {
return $film->actors()->toPages()->has($page);
});