Hello everybody,
I changed my website from Kirby 3.2 to the latest 3.5.3. I didn’t touch any of my template coding but I get an error message now:
“Call to a member function filterBy() on null”
This is my code for home.php:
?php $article = $site->index()
->visible()
->filterBy('intendedTemplate', 'article')
->sortBy('date', 'desc')
->first()
?>
<div class="enter"><a href="<?= $article->url() ?>">Enter</a></div>
Something similar happens on any other page with the template article.php (the page navigation)
<?php
$articles = $site->index()
->visible()
->filterBy('intendedTemplate', 'article')
->sortBy('date', 'desc');
$index = $articles->indexOf($page);
$last = $articles->count() - 1;
$prev = $index > 0 ? $articles->nth($index - 1) : null;
$next = $index < $last ? $articles->nth($index + 1) : null;
?>
In both templates the intendedTemplate-thisng causes the error.
What do I want to achieve?
The website is sort of a scrap book. The articles appear in the order of publication, one after another.
The homepage is the entrance page that leads to the latest publication (“article”). The latest article leads to the earlier one. On page (article) three you can move on to the previous or the next article, and so on.
This setup worked nicely with 3.2, but not with Kirby 3.5.3 anymore. I tested the newest version both with PHP 7.4 and PHP.8: no difference. The panel works.
What happened here?