pre_boucle

The pipeline pre_boucle modifies the SQL queries that result from the interpretation of the loops of SPIP. It is called at each compilation phase, after the compiler has already taken into account the selection criteria (the critere_NAME() functions), and before the call to the boucle_NAME() functions.

It receives as argument a "Boucle" object that contains the data issued from the previous compilation steps for the current loop.

It is therefore possible to take actions based on the criteria that are passed to the loop, like modifying the selection parameters or the "where" condition for the loop’s SQL query.

Example

The "mots techniques" plugin adds a technical field to the groups of keywords of SPIP.

When there is no {technique} criteria passed to the loop GROUPE_MOTS, the loop automatically filters its results, returning only those where the field {technique} is empty. This same feature could also be implemented by creating a function called boucle_GROUPES_MOTS().