Hello,
I'm using Phalcon 2.0.10 and facing a problem with the volt engine. Is there a way to use dynamic keys for the options in a partial call? I tried the following without success:
{{ partial('shared/pagetitle', ['title' : t._('My title'), 'breadcrumb': ['/link/to/' ~ model.id: t._('My second title')]]) }}
or
{% set linkto = '/link/to/' ~ model.id %}
{{ partial('shared/pagetitle', ['title' : t._('My title'), 'breadcrumb': [linkto: t._('My second title')]]) }}
or
{% set breadcrumb = ['/link/to/' ~ model.id: t._('My second title')] %}
{{ partial('shared/pagetitle', ['title' : t._('My title'), 'breadcrumb': breadcrumb]) }}
or
{% set linkto = '/link/to/' ~ model.id %}
{% set breadcrumb = [linkto: t._('My second title')] %}
{{ partial('shared/pagetitle', ['title' : t._('My title'), 'breadcrumb': breadcrumb]) }}
This is the error message i get:
Phalcon\Mvc\View\Exception: Syntax error, unexpected token COLON in XYZ
Even with a filter it doesn't work (is $this the real context from the view?) or is just to complex when using $exprArgs:
$voltcompiler->addFunction('breadcrumb', function ($resolvedArgs, $exprArgs) {
var_dump($resolvedArgs, $exprArgs);
// $resolvedArgs => array('/link/to/' . $this->model->id, $this->t->_('My second title'))
/* $exprArgs =>
array (size=1)
0 =>
array (size=3)
'expr' =>
array (size=4)
'type' => int 360
'left' =>
array (size=2)
0 =>
array (size=3)
'expr' =>
array (size=5)
....
*/
});
// usage in volt template
{% set bc = breadcrumb(['/link/to/' ~ model.id, t._('My second title')])
{{ partial('shared/pagetitle', ['title' : t._('My title'), 'breadcrumb': bc]) }}
Anyone has some suggestions how i can resolve this?