Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Public Attributes | List of all members
eZTemplateSwitchFunction Class Reference
Template system » Template functions

Handles conditional output in templates using function "switch". More...

## Public Member Functions
| __construct ()
| functionList ()
| functionTemplateHints ()
| attributeList ()
| templateNodeCaseTransformation ( $tpl, &$newNodes, &$caseNodes, &$caseCounter, &$node, $privateData)
| templateNodeTransformation ( $functionName, &$node, $tpl, $parameters, $privateData)
| process ( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace)
| hasChildren ()

## Public Attributes
| $SwitchName
| The name of the switch function. More...

## Detailed Description

Handles conditional output in templates using function "switch".

This allows for writing switch/case sentences (similar to if/else if/else) which you normally find in programming languages. With this you can display text depending on a certain template variable.

// Example template code
{* Matches $a against $b or $c *}
{switch match=$a}
{case match=$b}
Matched $b
{/case}
{case match=$c}
Matched $c
{/case}
{/switch}

TODO: Add support for custom operations when matching {case process=$match|gt(5)} Matched $c {/case}

Definition at line 42 of file eztemplateswitchfunction.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZTemplateSwitchFunction::__construct | ( |  | ) |

Initializes the function with the name $name, default is "switch".

Definition at line 47 of file eztemplateswitchfunction.php.

## Member Function Documentation

## ◆ attributeList()

eZTemplateSwitchFunction::attributeList | ( |  | ) |

Returns the attribute list which is case.

Definition at line 72 of file eztemplateswitchfunction.php.

## ◆ functionList()

eZTemplateSwitchFunction::functionList | ( |  | ) |

Returns an array of the function names, required for eZTemplate::registerFunctions.

Definition at line 55 of file eztemplateswitchfunction.php.

## ◆ functionTemplateHints()

eZTemplateSwitchFunction::functionTemplateHints | ( |  | ) |

Definition at line 60 of file eztemplateswitchfunction.php.

## ◆ hasChildren()

eZTemplateSwitchFunction::hasChildren | ( |  | ) |

Returns true.

Definition at line 362 of file eztemplateswitchfunction.php.

## ◆ process()

eZTemplateSwitchFunction::process | ( |  | $tpl,
|  | & | $textElements,
|  |  | $functionName,
|  |  | $functionChildren,
|  |  | $functionParameters,
|  |  | $functionPlacement,
|  |  | $rootNamespace,
|  |  | $currentNamespace
| ) |  |

Processes the function with all it's children.

Definition at line 212 of file eztemplateswitchfunction.php.

References eZTemplate\NODE_FUNCTION, and eZTemplate\NODE_TEXT.

## ◆ templateNodeCaseTransformation()

eZTemplateSwitchFunction::templateNodeCaseTransformation | ( |  | $tpl,
|  | & | $newNodes,
|  | & | $caseNodes,
|  | & | $caseCounter,
|  | & | $node,
|  |  | $privateData
| ) |  |

Definition at line 77 of file eztemplateswitchfunction.php.

References eZTemplateNodeTool\createCodePieceNode(), eZTemplateNodeTool\createSpacingDecreaseNode(), eZTemplateNodeTool\createSpacingIncreaseNode(), eZTemplateNodeTool\createVariableNode(), eZTemplateNodeTool\elementConstantValue(), eZTemplateNodeTool\extractFunctionNodeChildren(), eZTemplateNodeTool\isConstantElement(), eZTemplateCompiler\processElementTransformationList(), and eZTemplateCompiler\processNodeTransformationNodes().

Referenced by templateNodeTransformation().

## ◆ templateNodeTransformation()

eZTemplateSwitchFunction::templateNodeTransformation | ( |  | $functionName,
|  | & | $node,
|  |  | $tpl,
|  |  | $parameters,
|  |  | $privateData
| ) |  |

Definition at line 136 of file eztemplateswitchfunction.php.

References eZTemplateNodeTool\createCodePieceNode(), eZTemplateNodeTool\createNamespaceChangeNode(), eZTemplateNodeTool\createNamespaceRestoreNode(), eZTemplateNodeTool\createVariableNode(), eZTemplateNodeTool\createVariableUnsetNode(), eZTemplateNodeTool\elementConstantValue(), eZTemplateNodeTool\extractFunctionNodeChildren(), eZTemplateNodeTool\extractFunctionNodePlacement(), eZTemplateNodeTool\isConstantElement(), eZTemplate\NAMESPACE_SCOPE_RELATIVE, eZTemplate\NODE_FUNCTION, and templateNodeCaseTransformation().

## Member Data Documentation

## ◆ $SwitchName

eZTemplateSwitchFunction::$SwitchName

The name of the switch function.

Definition at line 368 of file eztemplateswitchfunction.php.

The documentation for this class was generated from the following file:

- eztemplateswitchfunction.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.