I've got custom fluid ViewHelper that returns an array, and I'd like to access a value of this array directly in one command.
Currently I'm using two commands:
{vendor:helper() -> v:variable.set(name: 'data')}
Value of foo: {data.foo}
Is there a way to do this in a single command? v:variable.get
does not seem suited for this task.
As @Jpsy said, there is the VHS Variable / GetViewHelper.
But the usage should be {v:variable.get(name: '{vendor:helper()}.foo')}
.
If you need the returned array of your viewhelper multiple times in your template, it's better to use it the way you already did. Because otherwise you would call the PHP method behind the viewhelper to build and return the array each time you want to access an index of an already previously built array again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With