Fluid: Direct access to the value of the array returned by the view helper

I have a custom ViewHelper fluid that returns an array, and I would like to access the value of this array directly in one command.

I am currently using two commands:

{vendor:helper() -> v:variable.set(name: 'data')}
Value of foo: {data.foo}

Is there a way to do this in one team? v:variable.getnot suitable for this task.

+4
source share
4 answers

It also depends on what you are really trying to achieve. If you want to detect an array, you must create a different view. If you want to create an array and then access all the data in a different position, you are looking for an auxiliary fluid f: alias

, , viewhelper . , ,

0

v:variable.get VHS viewhelpers , :

{v:variable.get(name: 'data.{foo}')}

{foo} .

0

@Jpsy, VHS Variable/GetViewHelper.

{v:variable.get(name: '{vendor:helper()}.foo')}.

viewhelper , , . PHP, , , .

0

You write that you are using a custom ViewHelper. Can you change it?

Inside ViewHelper, you can easily assign a variable with:

$this->templateVariableContainer->add('variable', 'content');

0
source

Source: https://habr.com/ru/post/1615730/


All Articles