| Under Construction This proposal is under construction and is not ready for review. |
Zend Framework: Zend_View_Helper_Loop Component Proposal
| Proposed Component Name | Zend_View_Helper_Loop |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_View_Helper_Loop |
| Proposers | My E-mail Address |
| Revision | 0.9 - 5 March 2008: First draft. (wiki revision: 3) |
Table of Contents
1. Overview
Zend_View_Helper_Loop is a view helper that simplifies iterating over arrays and iterable objects and also simplifies common operations during the iteration.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
4. Dependencies on Other Framework Components
- Zend_View_Exception
5. Theory of Operation
Zend_View_Helper_Loop wraps array or Iterator into Zend_View_Helper_Loop_Iterator and provides access to it. Zend_View_Helper_Loop_Iterator provides suplemental methods for:
- modifying iteration process befor starting
- setMax()
- setStep()
- setStart()
- retrieving iteration info while processing
- isFirst()
- isLast()
- getIndex()
- getIteration()
- getTotal()
See the use cases.
6. Milestones / Tasks
7. Class Index
- Zend_View_Helper_Loop
- Zend_View_Helper_Loop_Iterator
8. Use Cases
| Iterate over array |
|---|
inside view script:
Outputs:
Value: 3 Index: 2 Iteration: 1 Is first: No Is last: No Is odd: Yes Value: 5 Index: 4 Iteration: 2 Is first: No Is last: No Is odd: No Value: 7 Index: 6 Iteration: 3 Is first: No Is last: No Is odd: Yes Value: 9 Index: 8 Iteration: 4 Is first: No Is last: No Is odd: No Value: 11 Index: 10 Iteration: 5 Is first: No Is last: Yes Is odd: Yes Total: 5
| Nested iterations |
|---|
Output:
<tr> <td>1</td> <td><strong>11</strong></td> <td>12</td> <td>13</td> <td>14</td> </tr> <tr> <td>2</td> <td><strong>21</strong></td> <td>22</td> <td>23</td> <td>24</td> </tr> <tr> <td>3</td> <td><strong>31</strong></td> <td>32</td> <td>33</td> <td>34</td> </tr>
9. Class Skeletons
Labels:
None
2 Comments
comments.show.hideMay 14, 2008
Wil Sinclair
Martin, is this proposal ready for review at this point? If so, please reparent it to the 'ready for review' section and announce it's availability for review on the mailing list.
Thanks.
,Wil
Jun 16, 2008
Matthew Ratzloff
I'm sorry, I don't understand what value this proposal would add to the looping process. It doesn't look like anything is simplified at all. If anything, it looks more complicated.