I have a multi-language site but not all pages have an equivalent translation (such as individual blog posts). Is there a solution that excludes translated pages if not translated? I’m aware of this one solution where you add a toggle(true/false) field that can control translated pages. But as far as I’m aware this would still create an URL that is accessible by everyone.
It has been a while since the last time I’ve worked with Kirby. Now I’m back and came to this multilanguage issue.
I think there was an isTranslated() in Kirby 2 but I haven’t found the equivalent for Kirby 3.
I believe you should be able to do that applying this filter function on a Pages collection:
Thank you @sebastiangreger! This is it!
If anyone is interested my current solution with starter kit notes looks like this
<?php
$translatedPages = page('notes')->children()->filter(function ($child) {
return $child->translation(kirby()->language()->code())->exists();
});
?>
<?php foreach ($translatedPages->listed()->sortBy('date', 'desc') as $note): ?>
<a href="<?= $note->url() ?>">
<h2><?= $note->title() ?></h2>
<time><?= $note->date()->toDate('d F Y') ?></time>
</a>
<?php endforeach ?>