Hi there,
I need to store some content in a mySQL database and allow editors to make changes in the panel, using multiple languages. Everything is working (overriding the children() function on a parent page to get the content, overriding writeContent on the extended Page to update the content, including translations based on the languageCode) apart from one thing. I can’t get the translated content to appear in the panel. All that appears is the default language content. Here is my overrided children function() - I’ve amended it to just try passing in hard-coded values to the translations array, but even they don’t show up. What am I getting wrong/is there something else required to get the translations to show up in the panel? Many thanks for any thoughts
public function children()
{
$areas = [];
foreach (Db::select('cc_areas') as $area)
{
$content = [
'id' => $area->id(),
'title' => $area->name() ?? 'New area',
];
$contentEn = [
'description' => $area->description(),
];
if ($areaDe=Db::first('cc_areas_translations', '*', 'area_id='.$area->id().' and language_code="de"'))
{
$contentDe = [
'description' => $areaDe->description(),
];
}
$areas[] = [
'template' => 'area',
'slug' => Str::slug($area->name()),
'model' => 'area',
'num' => $area->id(),
'content' => array_merge($content, $contentEn),
'translations' => [
[
'code' => 'en',
//this is where I should be using the translated content from the database above, I can't even pass in hard-coded values
'content' => ['description'=>'en-test', ]
],
[
'code' => 'de',
//this is where I should be using the translated content from the database above, I can't even pass in hard-coded values
'content' => ['description'=>'de-test', 'translatedTitle'=>'hi', 'wewewe'=>'wewew', 'areaId'=>55],
],
]
];
}
return Pages::factory($areas, $this);
}