[TYPO3-mvc] <f:elseif condition="">
Laurent Foulloy
yolf.typo3 at orange.fr
Tue Aug 10 12:20:35 CEST 2010
Martin Kutschker a écrit :
> Yes, please :)
>
1) In the if view helper :
public function render($condition, $then = NULL, $else = NULL, $elseif =
NULL) {
if ($condition) {
return $this->renderThenChild();
} else {
$renderElseIfChild = $this->renderElseIfChild();
if ($renderElseIfChild === NULL) {
return $this->renderElseChild();
} else {
return $renderElseIfChild;
}
}
}
and
protected function renderElseIfChild() {
foreach ($this->childNodes as $childNode) {
if ($childNode instanceof
Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
&& $childNode->getViewHelperClassName() ===
'Tx_SavLibraryMvc_ViewHelpers_ElseifViewHelper') {
$childNode->setRenderingContext($this->renderingContext);
$data = $childNode->evaluate();
return $data;
}
}
if ($this->arguments->hasArgument('elseif')) {
return $this->arguments['elseif']['condition'] ?
$this->arguments['elseif']['then'] : NULL;
}
return NULL;
}
2) The elseif viewhelper
public function render($condition) {
if ($condition) {
return $this->renderChildren();
} else {
return NULL;
}
}
More information about the TYPO3-project-typo3v4mvc
mailing list