简体   繁体   English

将数组从ViewHelper发送到Fluidtemplate并打印输出

[英]Send Array from ViewHelper to the Fluidtemplate and printout

I'm working with Typo3, extbase and fluid. 我正在使用Typo3,extbase和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. 我将从一个php文件中获得一个数组(多维关联数组)到我的流体模板中,并使用循环将其打印出来。 I already have a own ViewHelper but I dont know how to send it to the template. 我已经有一个自己的ViewHelper,但是我不知道如何将其发送到模板。 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 如果还有另一种(简单)的方法,请告诉我

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? 但是,您需要使用什么viewviewer? You can traverse through arrays in fluid with the already available viewhelpers, for example: 您可以使用已经可用的viewhelper在流体中遍历数组,例如:

<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. 您可以嵌套这些viewhelper,因此多维数组应该不是问题,因为它们不是动态的或过于复杂的。

(As seen in the fluid documentation ) (如流体文档中所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM