The DATA loop

  • New in : SPIP 3.0

The DATA loop is able to iterate on a set of data of a certain format.

Its syntax is as follows:

<BOUCLE_display(DATA){source format,data}> 
 [(#CLE)] - [(#VALEUR|print)] 

The criterion {source format, data} defines the data on which the loop will iterate.

— The format can be of this type:
-  PHP array: table|array
-  Local file collections: ls|preg_files
-  File contents (local or remote): file|csv|json|xml|rss|yaml|...
-  Commands: sql|yql|ics|liste|enum|plugins|...

— The data can be of several kinds, depending on the format :
-  a PHP array
-  the path of a file or folder on the hard disk
-  the URL of a file or a webservice (API)
-  or any string that the format will be able to transform into a data table, ex: "select * from where text='spip'"

The following criteria are used to filter the tables displayed by the DATA loops.
-  {value=x} ; the available operators are =, >, <, >=, <=, ==(rational expression) and LIKE.
-  {par xx} and {!par xx}
-  {a,b} et {pagination ...}
-  {fusion /x/y}
-  {datapath path/to/my/data}

A complete chapter details the usage of DATA loops, provides usage examples and presents how to declare new DATA loops.

Read more : Iterators for SPIP - the (DATA) loop.

Author jack Published : Updated : 23/07/23

Translations : English, français, Nederlands