Skip to content

Kirby 3.7.5

Quicktip: Filtering by language

In a multi-language setup, Kirby falls back to returning the contents of the default language if it can't find a translated content file.

To prevent this, for example when displaying the pages for a menu or a list of articles, we have to filter the pages. Here's how to do this using Kirby's translation() method within a filter callback:

<?php

$translatedPages = page('somepage')->children()->filter(function ($child) {
  return $child->translation(kirby()->language()->code())->exists();
});