@@ -9,7 +9,7 @@ To add elements to cycle, specify them in constructor:
9
9
``` php
10
10
<table >
11
11
<?php foreach ($this->books as $book): ?>
12
- <tr style = " background-color : <?= $this->cycle([' #F0F0F0 ' , ' #FFF ' ])- >next () ?>" >
12
+ <tr class = " <?= $this->cycle(['odd ', 'even '])->next() ?>" >
13
13
<td ><?= $this->escapeHtml($book['author']) ?></td >
14
14
</tr >
15
15
<?php endforeach ?>
@@ -20,10 +20,10 @@ The output:
20
20
21
21
``` php
22
22
<table >
23
- <tr style = " background-color : #F0F0F0 " >
23
+ <tr class = " odd " >
24
24
<td >First</td >
25
25
</tr >
26
- <tr style = " background-color : #FFF " >
26
+ <tr class = " even " >
27
27
<td >Second</td >
28
28
</tr >
29
29
</table >
@@ -32,15 +32,15 @@ The output:
32
32
Instead of passing the data at invocation, you can assign it ahead of time:
33
33
34
34
``` php
35
- <?php $this->cycle()->assign(['#F0F0F0 ', '#FFF']) ); ?>
35
+ <?php $this->cycle()->assign(['odd ', 'even'] ); ?>
36
36
```
37
37
38
38
You can also cycle in reverse, using the ` prev() ` method instead of ` next() ` :
39
39
40
40
``` php
41
41
<table >
42
42
<?php foreach ($this->books as $book): ?>
43
- <tr style = " background-color : <?php echo $this->cycle()- >prev () ?>" >
43
+ <tr class = " <?= $this->cycle()->prev() ?>" >
44
44
<td ><?php echo $this->escapeHtml($book['author']) ?></td >
45
45
</tr >
46
46
<?php endforeach ?>
@@ -51,11 +51,11 @@ The output of the two previous examples combined becomes:
51
51
52
52
``` php
53
53
<table >
54
- <tr style = " background-color : #FFF " >
55
- <td >First</td >
54
+ <tr class = " even " >
55
+ <td >First</td >
56
56
</tr >
57
- <tr style = " background-color : #F0F0F0 " >
58
- <td >Second</td >
57
+ <tr class = " odd " >
58
+ <td >Second</td >
59
59
</tr >
60
60
</table >
61
61
```
@@ -64,12 +64,12 @@ The output of the two previous examples combined becomes:
64
64
65
65
If you are nesting cycles, you must provide all but one of them with a name; do
66
66
this by providing a second parameter to the ` cycle() ` invocation:
67
- ` $this->cycle(array('#F0F0F0 ', '#FFF '), 'cycle2') `
67
+ ` $this->cycle(array('odd ', 'even '), 'cycle2') `
68
68
69
69
``` php
70
70
<table >
71
71
<?php foreach ($this->books as $book): ?>
72
- <tr style = " background-color : <?= $this->cycle([' #F0F0F0 ' , ' #FFF ' ])- >next () ?>" >
72
+ <tr class = " <?= $this->cycle(['odd ', 'even '])->next() ?>" >
73
73
<td ><?= $this->cycle([1, 2, 3], 'number')->next() ?></td >
74
74
<td ><?= $this->escapeHtml($book['author']) ?></td >
75
75
</tr >
@@ -89,12 +89,12 @@ As a combined example:
89
89
90
90
``` php
91
91
<?php
92
- $this->cycle()->assign(['#F0F0F0 ', '#FFF '], 'colors ');
92
+ $this->cycle()->assign(['odd ', 'even '], 'classes ');
93
93
$this->cycle()->assign([1, 2, 3], 'numbers');
94
94
?>
95
95
<table >
96
96
<?php foreach ($this->books as $book): ?>
97
- <tr style = " background-color : <?= $this->cycle()- >setName ('colors ')- >next () ?>" >
97
+ <tr class = " <?= $this->cycle()->setName('classes ')->next() ?>" >
98
98
<td ><?= $this->cycle()->setName('numbers')->next() ?></td >
99
99
<td ><?= $this->escapeHtml($book['author']) ?></td >
100
100
</tr >
0 commit comments