Blocks:loop

Материал из Dwoo Docs

(Redirected from Loop)
Перейти к: навигация, поиск

Loops over an array of arrays and allows for really simple / small constructs by moving the scope down to each element automatically. It is basically a combination of foreach and with internally.

loop(array $from [, $name = "default ] )

Note that this plugin supports iterator variables through the name parameter and also supports the else plugin




Example:

{loop $users}
{$id}-{$name}
{/loop}

Data:

'users' => array(
  array( 'id' => 1, 'name' => 'Bob'),
  array( 'id' => 2, 'name' => 'John' )
)

Output:

1-Bob
2-John 

[edit] Accessing the array key

To access the array key you have to use the {$_key} var within the loop, its name is not user-definable to keep this plugin as simple as possible.

[edit] Extra reads

templates
page language

English

The article you want to access doesn't exist in English.
French
The article you want to access doesn't exist in French.
Deutsch
The article you want to access doesn't exist in Deutsch.