// Register twig on container
$container['view'] = function ($container) {
$settings = $container->get('settings');
$view = new \Slim\Views\Twig(
$settings['view']['template_path'],
$settings['view']['twig']
);
// Instantiate and add Slim specific extension
$view->addExtension(new SpecialExtension($container));
// global twig values
$view->offsetSet('common', 'src/Common/views/');
return $view;
};
So what you can do, is write a extension, that will do something like this:
{{ translate($item, ‘product.description’, $lang) }}
or something along that way.
Just a complete other direction:
if your iten is an object (a model-class), you could perhaps do:
{{ item.getDescription(lang) }}
or something along that way.
and inside the model-class, have a function that handles that call.
I am not quit there. Will get the correct name returned. Only now accessing this (and displaying) is something I don’t understand.
{{ go_compact('item.', 'name_', page.lang ) }}
public function goCompact($val1, $val2, $val3)
{
$var = $val1;
$var .= $val2;
$var .= $val3;
return $var;
}
// Output = item.name_en > that's correct. But I would like to access the array/object.