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
];