🚀 A new era: Kirby 4 Get to know
Skip to content

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:


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