#CHAMP_SQL is used to extract any SQL field associated with a loop.

The #CHAMP_SQL tag can be used in any loop and makes it possible to retrieve a field value from an SQL table. #CHAMP_SQL is very useful when a tag of the same name as the field already exists in SPIP (with multibases, for example). Let’s look at the example of The search loops and tags which are included in the core of SPIP; to extract a #POINTS field, we absolutely must use #CHAMP_SQL{points}, otherwise SPIP’s compiler will assume that we are calling the #POINTS tag which may only occur inside a loop that uses the {recherche} criterion.

Remarks: The #CHAMP_SQL tag can not use a dynamically referenced parameter value - it absolutely must be a constant which is used as the parameter. #CHAMP_SQL{points} works correctly, but #CHAMP_SQL{#GET{champ}} will fail.

In general, SPIP’s developers have used field names that do not coincide with functional tag names, meaning that this tag is normally only used when referencing custom fields or fields in custom tables that you are not at liberty to rename in order to avoid such confusion in the SPIP compiler.

Author Mark Published : Updated : 26/10/12

Translations : عربي, català, English, Español, français, Nederlands