TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Fluid\ViewHelpers\ForViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\ForViewHelper:
TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface Tx_Fluid_ViewHelpers_ForViewHelper

Public Member Functions

 render ($each, $as, $key='', $reverse=FALSE, $iteration=NULL)
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 setArguments (array $arguments)
 
 setRenderingContext (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 isEscapingInterceptorEnabled ()
 
 setViewHelperNode (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node)
 
 setRenderChildrenClosure (\Closure $renderChildrenClosure)
 
 initializeArgumentsAndRender ()
 
 initialize ()
 
 renderChildren ()
 
 prepareArguments ()
 
 validateArguments ()
 
 initializeArguments ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
 resetState ()
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 

Static Public Member Functions

static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 

Additional Inherited Members

- Protected Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 registerArgument ($name, $type, $description, $required=FALSE, $defaultValue=NULL)
 
 overrideArgument ($name, $type, $description, $required=FALSE, $defaultValue=NULL)
 
 callRenderMethod ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 
- Protected Attributes inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = NULL
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = TRUE
 

Detailed Description

Loop view helper which can be used to interate over array. Implements what a basic foreach()-PHP-method does.

= Examples =

<f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo">{foo}</f:for> <output> 1234 </output>

f:for each="{fruit1: 'apple', fruit2: 'pear', fruit3: 'banana', fruit4: 'cherry'}" as="fruit" key="label"> {label}: {fruit} </f:for> <output>

  • fruit1: apple
  • fruit2: pear
  • fruit3: banana
  • fruit4: cherry

</output>

f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo" iteration="fooIterator"> Index: {fooIterator.index} Cycle: {fooIterator.cycle} Total: {fooIterator.total}{f:if(condition: fooIterator.isEven, then: ' Even')}{f:if(condition: fooIterator.isOdd, then: ' Odd')}{f:if(condition: fooIterator.isFirst, then: ' First')}{f:if(condition: fooIterator.isLast, then: ' Last')} </f:for> <output>

  • Index: 0 Cycle: 1 Total: 4 Odd First
  • Index: 1 Cycle: 2 Total: 4 Even
  • Index: 2 Cycle: 3 Total: 4 Odd
  • Index: 3 Cycle: 4 Total: 4 Even Last

</output>

Definition at line 61 of file ForViewHelper.php.

Member Function Documentation

◆ render()

TYPO3\CMS\Fluid\ViewHelpers\ForViewHelper::render (   $each,
  $as,
  $key = '',
  $reverse = FALSE,
  $iteration = NULL 
)

Iterates through elements of $each and renders child nodes

Parameters
array$eachThe array or to iterated over
string$asThe name of the iteration variable
string$keyThe name of the variable to store the current array key
boolean$reverseIf enabled, the iterator will start with the last element and proceed reversely
string$iterationThe name of the variable to store iteration information (index, cycle, isFirst, isLast, isEven, isOdd)
Returns
string Rendered string

Definition at line 74 of file ForViewHelper.php.

References TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\buildRenderChildrenClosure().

◆ renderStatic()

static TYPO3\CMS\Fluid\ViewHelpers\ForViewHelper::renderStatic ( array  $arguments,
\Closure  $renderChildrenClosure,
\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface  $renderingContext 
)
static
Parameters
array$arguments
\Closure$renderChildrenClosure
\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface$renderingContext
Returns
string
Exceptions

Implements TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface.

Definition at line 85 of file ForViewHelper.php.

References TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$renderChildrenClosure, and TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper\$templateVariableContainer.