[TYPO3-mvc] Viewhelper looping child objects stops after one child object shown

Henjo Hoeksma | Stylence me at henjohoeksma.nl
Sat Mar 23 23:44:30 CET 2013


Hi list,

I need a ViewHelper that calculates the percentage of a child object.

The child object contains a property called 'number' and I need to show the
percentage based upon the other child objects of the parent object.

I thought this would be easy: assign all the child objects to my viewhelper
and to some calculation there. It works, except for one thing: Only the
first child object is being returned when I start looping the others in my
VH.

Basically what I am doing is:

public function render($objects, $currentObject) {

$total = 0;
foreach ($objects as $object) {

$total = $total + $object->getNumber();

}
return $total;

}

What am I missing?

It is a 4.5 installation (extbase 1.3.3)

Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.


More information about the TYPO3-project-typo3v4mvc mailing list