I have a custom page method that finds all ‘show’ pages that reference $this in their ‘worksincluded’ field:
<?php
Kirby::plugin('jaume/page-methods', [
'pageMethods' => [
'includedInShows' => function () {
return page("shows")->childrenAndDrafts()->filter(function ($show) {
return $show->worksIncluded()->toPages()->has($this);
});
},
]
]);
And I use it in a pagesdisplay field as such:
shows:
label: Shows
type: pagesdisplay
query: page.includedInShows
This works well UNLESS $this page is a draft, in which case it fails i.e. the pagesdisplay field shows nothing.
Why would this be ?
Initially I though that the ‘worksincluded’ field at the ‘show’ pages did not include the ‘show’ pages when they were draft, and thus the ‘incudedInShows’ did not find them. But I believe that should not be the case because I use ‘childrenAndDrafts’ in ‘worksincluded’ as such:
worksIncluded:
label: Works Included
type: pages
query: kirby.page("works").childrenAndDrafts.notTemplate("gap")
So what is going on ? Something simple I can’t see?
Thank you