Category : Technical Examples
It’s possible to modify the “looping” features in Docmosis so that the data can be looped through in small groups or steps.
The stepping feature can be used with Repeating Sections (<<rs_...>
This example explained
An array of colours: yellow, green, blue, purple, orange, pink and red, is passed to this template to illustrate how the “stepping across” and “stepping down” functions work.
IMPORTANT: When stepping Docmosis will automatically create the variables $i1, $i2, etc – so that you can identify and work with each item of data during each step.
Docmosis will create enough variables to cover all of the items. For example, if you are stepping in groups of 5 – Docmosis will create $i1, $i2, $i3, $i4 and $i5.
This example uses a Repeating Section to show the stepping-across function.
The “:step3” directive indicates to loop through the colours in small groups of 3.
For the first row, the $i1, $i2 and $i3 variables shown on the template will correspond with the 1st, 2nd and 3rd colours given in the data.
For the second row, $i1, $i2 and $i3 will correspond to the 4th, 5th and 6th colours.
In the third and final row, $i1 will correspond to the remaining 7th colour. The other variables $i2 and $i3 will be null and will produce no output in the final document.
This example shows how stepping-across can be applied to Repeating Rows.
Here, stepping is applied to a table with a 4-across layout through a “:step4” directive.
$i1, $i2, $i3, $i4 correspond to the 1st, 2nd, 3rd and 4th colours in the array.
During the next step, $i1, $i2, $i3 correspond to the 5th, 6th and 7th colours in the array. The $i4 variable will be null and will produce no output in the final document
In this example, the “:step2down” directive will arrange the colours downwards, filling the 2 columns evenly with data.
Docmosis automatically balances the data into the right number of rows, in this case 4 rows.
This results in the first four colours being shown in the first column and the remaining three colours being shown in the second column.
Here the “:step3down” directive shows the colours displayed in a downward fashion again, this time “balanced” over 3 columns.
Note that the last four colours are “balanced” evenly over the second and third columns, with two colours in each column. This is instead of three colours in the second column and one in the third column.
LEARN MORE: Download our Docmosis Quick Reference [PDF].