File: Zend_View-Helpers-Cycle.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (70 lines) | stat: -rw-r--r-- 2,240 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect3 id="zend.view.helpers.initial.cycle">
    <title>Cycle Helper</title>

    <para>
        The <classname>Cycle</classname> helper is used to alternate a set of values.
    </para>

    <example id="zend.view.helpers.initial.cycle.basicusage">
        <title>Cycle Helper Basic Usage</title>

        <para>
            To add elements to cycle just specify them in constructor
            or use <methodname>assign(array $data)</methodname> function
        </para>

        <programlisting language="php"><![CDATA[
<?php foreach ($this->books as $book):?>
  <tr style="background-color:<?php echo $this->cycle(array("#F0F0F0",
                                                            "#FFFFFF"))
                                              ->next()?>">
  <td><?php echo $this->escape($book['author']) ?></td>
</tr>
<?php endforeach;?>

// Moving in backwards order and assign function
$this->cycle()->assign(array("#F0F0F0","#FFFFFF"));
$this->cycle()->prev();
?>
]]></programlisting>

        <para>
            The output
        </para>

        <programlisting language="php"><![CDATA[
<tr style="background-color:'#F0F0F0'">
   <td>First</td>
</tr>
<tr style="background-color:'#FFFFFF'">
   <td>Second</td>
</tr>
]]></programlisting>
    </example>

    <example id="zend.view.helpers.initial.cycle.advanceusage">
        <title>Working with two or more cycles</title>

       <para>
           To use two cycles you have to specify the names of cycles. Just set second parameter in
           cycle method. <command>$this->cycle(array("#F0F0F0","#FFFFFF"),'cycle2')</command>. You
           can also use setName($name) function.
        </para>
    </example>

    <programlisting language="php"><![CDATA[
<?php foreach ($this->books as $book):?>
  <tr style="background-color:<?php echo $this->cycle(array("#F0F0F0",
                                                            "#FFFFFF"))
                                              ->next()?>">
  <td><?php echo $this->cycle(array(1,2,3),'number')->next()?></td>
  <td><?php echo $this->escape($book['author'])?></td>
</tr>
<?php endforeach;?>
]]></programlisting>
</sect3>
<!--
vim:se ts=4 sw=4 et:
-->