For an archive project, I want to relate a set of paintings to the boxes they’re stored in.
There are two types of pages:
-
Page per box with a structure field that holds the numbers of paintings physically stored in that box (
kiste.yml
). -
Page per painting. A query should find the box this painting is stored in (
werk.yml
).
With a custom page model the correct box gets returned in the template:
class WerkPage extends Page
{
public function getKiste()
{
$kisten = site()->index()->filterBy('intendedTemplate', 'kiste');
foreach ($kisten as $kiste)
{
$in_kiste = $kiste->archivnummern()->toStructure()->filterBy('archivnummer', $this->uid());
if ($in_kiste)
{
return $kiste->title();
}
}
return false;
}
}
How can this function be called in the blueprint of the painting-page?
This, for example, seems not to work:
fields:
kiste:
type: select
options: query
query: page.getKiste
It returns this:
Invalid query result data