Feature #3595

Convert integer types to boolean for if viewhelper

Added by Balisky Christophe over 12 years ago. Updated about 11 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
Has patch:


Hello, after wndeirng why certain if conditions didn't work in my flow templates, i figures out it was because it didn't convert interger values to boolean correctely. I suggest modifiying the convertArgumentValue method in the Tx_Fluid_Core_SyntaxTree_ViewHelperNode accordingly. Positive integer values superior to 0 are considered true all others are false.

 * Convert argument strings to their equivalents. Needed to handle strings with a boolean meaning.
 * @param mixed $value Value to be converted
 * @param string $type Target type
 * @return mixed New value
 * @author Sebastian Kurf├╝rst <>
 * @author Bastian Waidelich <>
 * @todo re-check boolean conditions
protected function convertArgumentValue($value, $type) {
//echo "<br>$value - $type";
if ($type === 'boolean') {
if (is_string($value)) {
//echo "string";
return (strtolower($value) !== 'false' && !empty($value));
if (is_array($value) || (is_object($value) && $value instanceof Countable)) {
//echo "array";
return count($value) > 0;
if (is_object($value)) {
//echo "object";
return TRUE;
//----> NEW CODE
if (is_integer($value)) {
//echo "integer";
return $value > 0;
// END NEW CODE ---->
return FALSE;
return $value;

Related issues

Related to TYPO3.Fluid - Bug #8893: Negative numeric values are not correctly converted to FALSEResolvedBastian Waidelich2010-07-15

Is duplicate of TYPO3.Fluid - Bug #3412: ViewHelperNode.php -> convertArgumentValue() -- wrong handling of integers and booleansResolvedBastian Waidelich2009-05-22


Updated by Bastian Waidelich over 12 years ago

  • Status changed from New to Closed
  • Assignee set to Bastian Waidelich

This was fixed in r2345.
See http://forge.typo3.org/issues/show/3412


Updated by Robert Lemke over 12 years ago

  • Target version set to 1.0.0 alpha 2

Also available in: Atom PDF