I use a custom pages method to extract the titles of all pages in a pages field, to show them as info in a pages section.
The pages field include childrenAndDrafts, like this:
fields:
curator:
label: Curator(s)
type: pages
query: kirby.page("curators").childrenAndDrafts
I’ve noticed that ‘draft’ pages titles do not show. I am a bit confused about this.
This is the custom method:
<?php
Kirby::plugin('jaume/pagesMethods', [
'pagesMethods' => [
'eachTitle' => function () {
$titles = '';
if ($this->isNotEmpty()) {
forEach($this as $page) {
$titles .= $page->title();
if ($page->isLast($this)) {
$titles .= ' | ';
} else {
$titles .= ', ';
}
}
}
return $titles;
}
]
]);
And I call it in the blueprint like this:
sections:
shows:
type: pages
template: show
parent: kirby.page("shows")
info: '{{page.curator.toPages.eachTitle}}'
image: page.selectedimages.toFiles.first
status: all
Can someone explain if my code is doing something I haven’t noticed or if the visibility system affects fetching info in this manner too?
Thank you