开发者

Zend Framework PartialLoop - questions

开发者 https://www.devze.com 2022-12-22 03:45 出处:网络
Ok dealing with Partial Loops I want to do several things 1- Perhaps pass in extra variables - seen it done like this

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 cannot extra the data using $this->var, $this->data->var or $data->var and I'm not sure how to access the data in the loop

2- Sutotals for columns 开发者_开发百科- I need a way of resetting variables or passing in a default value - linked to the above I suppose

i.e.

$subtotal += rowTotal;

3- 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.


I can be done with only a little extra code. The partialLoop Helper is happy with any array so the only thing you have to do is looping threw your rowset in the controller and move the data to a new array where you can add your additional variables for each row.

Then you pass this new array to the view and ultimately to the helper.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号