typo3fluidtypo3-6.2.x

How to define array of numbers and output it?


How can I define an array of numbers and output each number in a for loop?

I tried it like this:

  <f:alias map="{numbers: [1,2,3,4,5,6]}">
    <f:for each="{numbers}" as="number">
      <p>{number}</p>
    </f:for>
  </f:alias>

Result:

The argument "map" was registered with type "array", but is of type "string" in view helper "TYPO3\CMS\Fluid\ViewHelpers\AliasViewHelper"

And like this:

  <f:alias map="{v:iterator.explode(content: '1,2,3,4,5,6')}">
      <f:for each="{content}" as="zahl">
          <p>{zahl}</p>
      </f:for>
  </f:alias>

Result: No output.


Solution

  • <f:for each="{0:1, 1:2, 2:3, 3:4, 4:5, 5:6, 6:7}" as="foo">{foo}</f:for>