Send Array from ViewHelper to the Fluidtemplate and printout

908 Views Asked by At

I'm working with Typo3, extbase and fluid. I will get an array (multidimensional associative Array) from a php file into my fluid template and print it out there with a loop. I already have a own ViewHelper but I dont know how to send it to the template. They write something about the "controller" where you can initialize these variables but I don't understand it.

If there is another (simpler) way, please let me know it

1

There are 1 best solutions below

1
On

In your controller action, you can assign variables to your view with

public function listAction() {
    // ...
    $this->view->assign('yourArrayInFluid', $yourArray);
}

But what do you need a viewhelper for? You can traverse through arrays in fluid with the already available viewhelpers, for example:

<f:for each="{yourArrayInFluid}" as="yourValue" key="yourKey">
    <p>{yourValue}</p>
</f:for>

You can nest these viewhelpers, so multidimensional arrays should be no problem they aren't dynamic or too complex.

(As seen in the fluid documentation)