[fw-general] partialLoop() best practice
I use a partialLoop() to loop through query results in the view. So far so good. But for every item returned in the loop, I need to do another database query that returns another set of results that require a new partialLoop(). In the end I have a partialLoop() inside a partialLoop() inside a partialLoop(). But to be able to do the above, I have database queries and some php logic in the view inside every partialLoop() and that doesn't seem right if I want to follow the MVC principle. Is there a way to solve this? -- View this message in context: http://www.nabble.com/partialLoop%28%29-best-practice-tp21861311p21861311.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] partialLoop() best practice
I do not know if it's the best way, but could you not prepare all the arrays and variables and pass those to the first partialLoop, which passes certain levels to the next nested one and so on? -Bart bytte schreef: I use a partialLoop() to loop through query results in the view. So far so good. But for every item returned in the loop, I need to do another database query that returns another set of results that require a new partialLoop(). In the end I have a partialLoop() inside a partialLoop() inside a partialLoop(). But to be able to do the above, I have database queries and some php logic in the view inside every partialLoop() and that doesn't seem right if I want to follow the MVC principle. Is there a way to solve this?
Re: [fw-general] partialLoop() best practice
If you create view helpers you can call them from anywhere in the levels with this-helper(). I feel that having DB queries and php logic isn't right for a view script, but acceptable in a view helper (well, actually not DB queries, but model instantiation inside the view helpers...) - Ramon Bart McLeod wrote: I do not know if it's the best way, but could you not prepare all the arrays and variables and pass those to the first partialLoop, which passes certain levels to the next nested one and so on? -Bart bytte schreef: I use a partialLoop() to loop through query results in the view. So far so good. But for every item returned in the loop, I need to do another database query that returns another set of results that require a new partialLoop(). In the end I have a partialLoop() inside a partialLoop() inside a partialLoop(). But to be able to do the above, I have database queries and some php logic in the view inside every partialLoop() and that doesn't seem right if I want to follow the MVC principle. Is there a way to solve this?