I am sure this is not the first time I ask this, but I can’t find it.
When returning a snippet from a config route, how do I get it in the current page language?
This is my route:
'routes' => [
[
'pattern' => '(:any)/pop-artwork',
'method' => 'POST',
'action' => function () {
$id = get('id');
$all_ids = get('all_ids');
$snippet = page($id)->intendedTemplate() == 'artwork' ? 'pop-artwork' : 'pop-publication';
$res = [
'data' => [
'html' => snippet($snippet, array('id' => $id, 'all_ids' => $all_ids), true),
'url' => '',
'all_ids' => $all_ids
]
];
try {
return json_encode($res);
} catch (Exception $ex) {
return $ex->getMessage();
}
}
],
...
Thanks