SPIP

[ar] [bg] [ca] [cpf] [cs] [da] [de] [en] [eo] [es] [eu] [fa] [fon] [fr] [gl] [id] [it] [ja] [lb] [nl] [oc] [pl] [pt] [ro] [sv] [tr] [vi] [zh] Espace de traduction

Download the latest version of SPIP

SPIP 1.9.2 SPIP 1.9.2
Home page > English documentation > Webmasters > A few examples of loops > Displaying elements as rows in a table

Displaying elements as rows in a table

November 2003 — updated : April 2005

All the versions of this article:


For example, you want to create a table containing the titles of a section’s articles arranged in three columns, the number of lines depending on the total number of articles, like this:

article 1 article 2 article 3
article 4 article 5 article 6
article 7 article 8 article 9

This trick involves using the doublons (unique) criterion and recursive loops. You first build a loop which displays the first three articles of the section once doublons criterion eliminates duplicates. You can see that you just re-invoke this loop each time, gradually displaying all the remaining articles. For that, in the conditional code of this loop, you add a recursive call towards the parent loop, it will be invoked as long as it produces results.

The same type of loop, with the title tags replaced by logo tags (#LOGO_ARTICLE), allows a gallery display where each article logo (of which the size will preferably be fixed to give a balanced page layout) gives a thambnail.


ٍShow the template of this page Site created with SPIP | Translation area | Private area