TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper:
TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper TYPO3\CMS\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface

Public Member Functions

 initializeArguments ()
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper
 setChildNodes (array $childNodes)
 
 __construct ()
 
 render ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 setArguments (array $arguments)
 
 setRenderingContext (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
 injectObjectManager (\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 
 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)
 

Additional Inherited Members

- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper
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)
 
- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Protected Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper
 renderThenChild ()
 
 renderElseChild ()
 
- 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 ()
 
 getLogger ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 
- Static Protected Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper
static renderStaticThenChild ($arguments, &$hasEvaluated)
 
static renderStaticElseChild ($arguments, &$hasEvaluated)
 
static evaluateCondition ($arguments=null)
 
- Protected Attributes inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = null
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = true
 

Detailed Description

This view helper implements an if/else condition.

Conditions:

As a condition is a boolean value, you can just use a boolean argument. Alternatively, you can write a boolean expression there. Boolean expressions have the following form: XX Comparator YY Comparator is one of: ==, !=, <, <=, >, >= and % The % operator converts the result of the % operation to boolean.

XX and YY can be one of:

  • number
  • Object Accessor
  • Array
  • a ViewHelper
  • a String

    <f:if condition="{rank} > 100"> Will be shown if rank is > 100 </f:if> <f:if condition="{rank} % 2"> Will be shown if rank % 2 != 0. </f:if> <f:if condition="{rank} == {k:bar()}"> Checks if rank is equal to the result of the ViewHelper "k:bar" </f:if> <f:if condition="{foo.bar} == 'stringToCompare'"> Will result true if {foo.bar}'s represented value equals 'stringToCompare'. </f:if>

= Examples =

<f:if condition="somecondition"> This is being shown in case the condition matches </f:if> <output> Everything inside the <f:if> tag is being displayed if the condition evaluates to TRUE. </output>

<f:if condition="somecondition"> <f:then> This is being shown in case the condition matches. </f:then> <f:else> This is being displayed in case the condition evaluates to FALSE. </f:else> </f:if> <output> Everything inside the "then" tag is displayed if the condition evaluates to TRUE. Otherwise, everything inside the "else"-tag is displayed. </output>

{f:if(condition: someCondition, then: 'condition is met', else: 'condition is not met')} <output> The value of the "then" attribute is displayed if the condition evaluates to TRUE. Otherwise, everything the value of the "else"-attribute is displayed. </output>

Definition at line 82 of file IfViewHelper.php.

Member Function Documentation

◆ initializeArguments()

TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper::initializeArguments ( )