Finished improving designers docs

This commit is contained in:
Simon Wisselink
2023-02-06 14:42:31 +01:00
parent 694ff1b733
commit badcae6e0c
55 changed files with 1872 additions and 1842 deletions
@@ -1,22 +1,23 @@
{cycle} {#language.function.cycle}
=======
# {cycle}
`{cycle}` is used to alternate a set of values. This makes it easy to
for example, alternate between two or more colors in a table, or cycle
through an array of values.
Attribute Name Type Required Default Description
---------------- --------- ---------- ----------- -------------------------------------------------------------------------------------------------------------
name string No *default* The name of the cycle
values mixed Yes *N/A* The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values
print boolean No *TRUE* Whether to print the value or not
advance boolean No *TRUE* Whether or not to advance to the next value
delimiter string No *,* The delimiter to use in the values attribute
assign string No *n/a* The template variable the output will be assigned to
reset boolean No *FALSE* The cycle will be set to the first value and not advanced
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|-------------------------------------------------------------------------------------------------------------|
| name | No | The name of the cycle |
| values | Yes | The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values |
| print | No | Whether to print the value or not (defaults to true) |
| advance | No | Whether or not to advance to the next value (defaults to true) |
| delimiter | No | The delimiter to use in the values attribute (defaults to ',') |
| assign | No | The template variable the output will be assigned to |
| reset | No | The cycle will be set to the first value and not advanced (defaults to false) |
- You can `{cycle}` through more than one set of values in a template
by supplying a `name` attribute. Give each `{cycle}` an unique
by supplying a `name` attribute. Give each `{cycle}` a unique
`name`.
- You can force the current value not to print with the `print`
@@ -30,20 +31,18 @@ through an array of values.
function will be assigned to a template variable instead of being
output to the template.
<!-- -->
{section name=rows loop=$data}
## Examples
```smarty
{section name=rows loop=$data}
<tr class="{cycle values="odd,even"}">
<td>{$data[rows]}</td>
</tr>
{/section}
{/section}
```
The above template would output:
```html
<tr class="odd">
<td>1</td>
</tr>
@@ -53,5 +52,4 @@ The above template would output:
<tr class="odd">
<td>3</td>
</tr>
```