1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect3 id="zend.view.helpers.initial.cycle">
4 <title>Cycle Helper</title>
7 The <classname>Cycle</classname> helper is used to alternate a set of values.
10 <example id="zend.view.helpers.initial.cycle.basicusage">
11 <title>Cycle Helper Basic Usage</title>
14 To add elements to cycle just specify them in constructor
15 or use <methodname>assign(array $data)</methodname> function
18 <programlisting language="php"><![CDATA[
19 <?php foreach ($this->books as $book):?>
20 <tr style="background-color:<?php echo $this->cycle(array("#F0F0F0",
23 <td><?php echo $this->escape($book['author']) ?></td>
27 // Moving in backwards order and assign function
28 $this->cycle()->assign(array("#F0F0F0","#FFFFFF"));
29 $this->cycle()->prev();
37 <programlisting language="php"><![CDATA[
38 <tr style="background-color:'#F0F0F0'">
41 <tr style="background-color:'#FFFFFF'">
47 <example id="zend.view.helpers.initial.cycle.advanceusage">
48 <title>Working with two or more cycles</title>
51 To use two cycles you have to specify the names of cycles. Just set second parameter in
52 cycle method. <command>$this->cycle(array("#F0F0F0","#FFFFFF"),'cycle2')</command>. You
53 can also use setName($name) function.
57 <programlisting language="php"><![CDATA[
58 <?php foreach ($this->books as $book):?>
59 <tr style="background-color:<?php echo $this->cycle(array("#F0F0F0",
62 <td><?php echo $this->cycle(array(1,2,3),'number')->next()?></td>
63 <td><?php echo $this->escape($book['author'])?></td>