Skip to content

Commit bc84d14

Browse files
committed
Document {section} template tag
Closes #513
1 parent 820ae7e commit bc84d14

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/view/templates.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ More examples:
250250

251251
### Foreach Loops
252252

253-
Foreach loops allow to iterate over arrays or iterable objects:
253+
Foreach loops allow to iterate over associative arrays or iterable objects:
254254

255255
```smarty
256256
<ul>
@@ -287,6 +287,39 @@ In contrast to PHP’s foreach loop, templates also support `foreachelse`:
287287
{/foreach}
288288
```
289289

290+
### Sections
291+
292+
Section loops allow iterations without the use associative arrays or iterable objects:
293+
294+
```smarty
295+
{section name=month start=1 loop=12}
296+
{$month}
297+
{/section}
298+
```
299+
300+
#### Parameters
301+
302+
| Name | Type | Required | Default | Description |
303+
|------|------|----------|---------|-------------|
304+
| name | string | Yes | n/a | The name of the section |
305+
| loop | mixed | Yes | n/a | Value to determine the number of loop iterations |
306+
| start | integer | No | 0 | The index position that the section will begin looping |
307+
| step | integer | No | 1 | The step value that will be used to traverse the loop array |
308+
| max | integer | No | n/a | The maximum number of times the section will loop |
309+
| show | boolean | No | true | Determines whether or not to show the section |
310+
311+
#### `{sectionelse}`
312+
313+
If the section loop does not perform any iterations, `{sectionelse}` can be defined for an alternative output:
314+
315+
```smarty
316+
{section name=name start=1 loop=$loop}
317+
318+
{sectionelse}
319+
there is nothing to iterate over
320+
{/section}
321+
```
322+
290323
### Including Other Templates
291324

292325
To include template named `foo` from the same domain (frontend/backend), you can use

0 commit comments

Comments
 (0)