0

我写了一些 ViewHelpers 工作得很好,但只在主部分......为了更好地理解:

<f:section name="Configuration">
  <flux:field.select name="first" label="first" items="{0: '10', 1: '40'}"/>
  <flux:field.select name="second" label="second" items="{myViewHelpers:load()}"/>
</f:section>
<f:section name="Preview">
</f:section>
<f:section name="Main">
  {myViewHelpers:load()}
</f:section>

{myViewHelpers:load()}返回一个字符串,例如

{0:'10',1:'40'}

在 Main-Section 中,这非常有效,但是如果我在 Configuration-section 中使用相同的 ViewHelper,它就不会再加载后端了……我在 Typo3 中只得到一个空白字段,通常是该元素出现的地方。

我将不胜感激任何建议!

4

1 回答 1

0

您的 ViewHelper 返回一个字符串,该字符串反过来被流体解释为一个数组(大括号)。所以流体什么也打印不出来。您确定不需要将该数组传递给另一个 ViewHelperflux:field.select吗?

如果您需要从 ViewHelper 生成可用数组,您应该使用

$templateVariableContainer = $renderingContext->getTemplateVariableContainer();
$templateVariableContainer->add($arguments['myNewVariable'], $array);

然后你可以像往常一样访问你的变量:

{myNewVariable.0}
于 2016-07-02T11:10:39.193 回答