Hi,
for reporting purposes I wrote a module extending the Page class.
In this simplified example I want to display the title of the most recent blog article in the “Predigten” folder.
class StatisticsPage extends Page
{
public function reports(): array
{
$letzteSeiteName = $site->pages()->find('Predigten')->children()->sortBy('Date', 'desc')->first()->title();
return [
[
'label' => 'Test',
'value' => $letzteSeiteName,
]
];
}
}
The problem occurs, when I use the line
$letzteSeiteName = $site->pages()->find('Predigten')->children()->sortBy('Date', 'desc')->first()->title();
then the report is just empty.
When I replace this line with
$letzteSeiteName = "Expample"
the report shows “Test: Example” as expected.
The very same line
$letzteSeiteName = $site->pages()->find('Predigten')->children()->sortBy('Date', 'desc')->first()->title();
works in normal page templates just fine.
What’s going on? Can anybody please explain?
Thanks,
Nikolaus