views:

39

answers:

1

Hi

Ok dealing with Partial Loops I want to do several things

  1. Perhaps pass in extra variables - seen it done like this echo $this->partialLoop('Loop.phtml', array('data' => $data, 'var1' => foo));

But this does not seem to work - I can not extra the data using $this->var $this->data->var or $data->var not sure how to access the data in the loop

  1. Sutotals for columns - need a way of resetting variables or passing in a default value - linked to the above I suppose

ie $subtotal += rowTotal;

  1. In the view that calls the partial I would like to get access to the subtotal values generated so I can display these in another table below.

Any help appreciated the docs on partialLoop seems incomplete.

Ian

A: 

You cannot pass in "extra" out of band data to the PartialLoop helper. Each iterable item in the second argument (model) will be looped over. Thus, if you specify anything extra in an array to that helper, it will be iterated in a loop and produce undesirable output.

To get around this, you can reference $this->view->var within the helper. $this->view always references the calling view, so you can access any view variable that way within the helper.

roktechie