Merge multilingual content from database and files

I am trying to merge some fields that come from Kirby .txt files with content that comes from a database. I used code from the https://getkirby.com/docs/guide/virtual-pages/merging-virtual-and-local-content tutorial.

In my example, I want to include the featured field. This specific field does not need to be translated, but others will. In the code below, if I include the featured key in the translations->content array, the application hangs. Any ideas about what’s wrong?

// Products model
// I skipped some variables and loops for brevity
$product = $db_products[$index]; // item from db
$page = $this->subpages()->find($productcode); // page from filesystem

$featured = false;

if (isset($page)) {
  if ($page->content()->featured()->isNotEmpty()) {
    $featured = $page->featured()->toBool();
  }
}

$products[] = [
  'slug' => Str::slug($productcode),
  'num' => 0,
  'template' => 'product',
  'translations' => [
    [
      'code' => 'el',
      'content' => [
        'item_title' => $product['title_el'],
        'featured' => $featured
      ]
    ],
    [
      'code' => 'en',
      'content' => [
        'item_title' => $product['title_en'],
        'featured' => $featured
      ]
    ]
  ],
  'files' => $page ? $page->files()->toArray() : null,
  'children' => $children
];

Does it work without the featured field?

Try using a string instead of the boolean value.

It works without the featured field. Even hardcoding a value like 'featured' => 'true' breaks it.

The $page folder from the filesystem may not exist, if no editing like changing fields or adding images happened. Also, .txt files may not exist, so the featured field will be absent if only images were added to the content folder.

To simplify things a bit, I want featured to be set to the value it has in the content file if that file exists, and null when not.

Is the field defined in your blueprint?

Yes, and it is a toggle field.

The problem was in another part of the application. Sorry!