Hey together,
I’m using this if statement to filter articles by a tag. This works as long as I have a multi language setup. I want to archive that I can delete the multi language setup without having to touch this code again. This would mean I have to do a check if languages exists before I use filter()
.
if (urldecode(param('tag'))) {
$articles = $page->children()
->listed()
->filter(function ($child) {
return $child->translation(kirby()->language()->code())->exists();
})
->filterBy('tags', $tag, ',')
->sortBy('date')
->flip();
}
I’m trying to find a solution by myself but all I came up with is this workaround which works but is not the proper way I guess.
->filter(function ($child) {
return kirby()->languages()->isNotEmpty() ? $child->translation(kirby()->language()->code()) : $child->template() == "article";
})