TYPO3  7.6
Public Member Functions | Static Public Member Functions | List of all members
ForViewHelper Class Reference
Inheritance diagram for ForViewHelper:
AbstractViewHelper CompilableInterface

Public Member Functions

 render ($each, $as, $key= '', $reverse=false, $iteration=null)
 
- Public Member Functions inherited from 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 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 AbstractViewHelper
static renderStatic (array $arguments,\Closure $renderChildrenClosure,\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from CompilableInterface
static renderStatic (array $arguments,\Closure $renderChildrenClosure,\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractViewHelper
 registerArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 overrideArgument ($name, $type, $description, $required=false, $defaultValue=null)
 
 callRenderMethod ()
 
 getLogger ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 
- Protected Attributes inherited from 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>

</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>

</output>

Definition at line 61 of file ForViewHelper.php.

Member Function Documentation

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
bool$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 AbstractViewHelper\buildRenderChildrenClosure().

static 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
\TYPO3\CMS\Fluid\Core\ViewHelper\Exception

Definition at line 90 of file ForViewHelper.php.

References AbstractViewHelper\$renderChildrenClosure, and AbstractViewHelper\$templateVariableContainer.