Bonux for SPIP 3.*

A great number of the features brought by the first version of SPIP Bonux have since then been fully incorporated into SPIP3. Some still haven’t yet, and those are brought by this new plugin’s version Bonux for SPIP3.

This post lists all tags, criterias & functions, that are defined by SPIP Bonux, for we can keep them in mind, but the documentation of those elements won’t appear on (see also other documentation posts to SPIP Bonux or even the source code).

Note: to avoid conflicts, some of these functionalities are defined by Bonux only if they have NOT been already defined elsewhere.

Tags, criteria & loops


  • #SET_PUSH stacks an element in an array, instantiated with #SET{my_array,#ARRAY}
  • #COMPTEUR (Counter)
  • #SOMME (Sum)
  • #COMPTE (Account)
  • #MOYENNE (Average)
  • #STATS

The tags #COMPTEUR, #COMPTE, #SOMME, #MOYENNE, #MINIMUM, #MAXIMUM and #STATS require using a criterion that specifies the field, which the Tag is calculated on.

Those criterions does not calculate any joint or relational database, contrary to the {compteur table} criterion which does.

Examples of usage :

-  #SET_PUSH : #SET_PUSH{my_array,my_value}

Statistics criteria

  • {compteur}
  • {compteur_left}
  • {somme}
  • {compte}
  • {moyenne}
  • {minimum}
  • {maximum}
  • {stats}

Examples of usage :

-  Let’s say an extra field ’distance’ was added to the ARTICLES objects (posts). The following loop will then calculate the sum (#SOMME) of the distances set in every article posted into section id n°1 (id_rubrique=1)

<BOUCLE_a(ARTICLES){id_rubrique=1}{somme distance}></BOUCLE_a>

-  In the plugin ’abonnement’ for example, the ’abonnements_stats ’ file gives several examples of those criteria.

For example:

<BOUCLE_nombre(AUTEURS_ELARGIS_ABONNEMENTS){id_abonnement}{statut_paiement=ok}{somme montant}{compte montant}{fusion id_abonnement}>
    <td>[(#SOMME{montant}|number_format{2, ',', ' '}|replace{' ','&nbsp;'})]</td>

Other criterion

{fusion_supprimer} : this criterion deletes from the SQL query the GROUP BY condition which is already implied, a this compilation step. That might be useful to get rid of a potential interfering GROUP BY, eventually added by default by SPIP’s compiler while joining tables. It then becomes possible to add a criterion for the desired merge (see issue #3209).

In the following loop, we have to add {fusion_supprimer} in order to get the merge on dates, because the compiler automatically adds a GOUP BY id_article to join the ARTICLES table (posts) to the MOTS table (keywords) :

<BOUCLE_year_featured(ARTICLES){id_mot=27}{fusion_supprimer}{fusion YEAR(date)}>
    [(#DATE|annee)]<br />

PHP functions

Bonux also defines a whole set of functions, that can be used as filters or by other plugins.

/** Get fields date_$suffixe and heure_$suffixe in the environment, 
check for their relevancy and re-format them */
function verifier_corriger_date_saisie($suffixe,$horaire,&$erreurs);
/** Returns the charset of a line, to be imported */
function importer_csv_importcharset($texte);
/** Removes accents from keys, to avoid problems ... */
function importer_csv_nettoie_key($key);
/** Reads a CSV file & returns an array
if $head is true, the first line is used as a header to generate an array*/
function inc_importer_csv_dist($file, $head = false, $delim = ",", $enclos = '"', $len = 10000) ;
/** Exports a field to a CSV export */
function exporter_csv_champ($champ) ;
/** Exports a full line, CSV formated, with specified delimiter */
function exporter_csv_ligne($ligne, $delim = ',', $importer_charset = null) ;
/** export as CSV. $resource is an array or any open readable SQL resource */
function inc_exporter_csv_dist($titre, $resource, $delim=',', $entetes = null,$envoyer = true);
/** generates an IMG tag from a file name */
function tag_img($img,$alt="",$class="");
/** generates a temporary key with 12h validation for the current URL */
function previsu_cle_temporaire($date=null);
/** checks if a 12h temporary key is valid */
function previsu_verifier_cle_temporaire($cle);
function _T_ou_typo($valeur, $mode_typo='toujours') ;
function spip_array_insert($arr1, $cle, $arr2, $avant=false);
function array_replace_recursive($array, $array1);
function recurse($array, $array1);
/** Truncates a string to the desired length, without harming HTML markup and, with options : end text if cut, cut to exact length or, respecting words... */
function text_truncate($text, $length = 100, $options = array()) 
/** return an array, containing every value in any column of any bi-dimensional table (possibly along values of another column, as an index) */
function array_column($input = null, $columnKey = null, $indexKey = null);

filtre text_truncate
function text_truncate($text, $length = 100, $options = array());

The options array can contain several couples of key/value:
-  ’ending’ => string added at the end of the text, if it has to be cut. Basically, it’ll be ’...’ or ’read more’.
-  ’exact’ => a boolean defining if it’s to be cut at the exact provided length, even if it’s in the middle of a word or, just before that last word.
-  ’html’ => a boolean defining if text contains any HTML tags that are not to be cut incorrectly.

array_column function

Loads the PHP 5.5 function array_column for older versions.

Read more : Array_column pour SPIP


-  |aoustrong filter is gone : it became |lien_ou_expose and was incorporated to SPIP.

updated on 6 April 2020


Aucune discussion

Ajouter un commentaire

Who are you?
[Log in]

To show your avatar with your message, register it first on (free et painless) and don’t forget to indicate your Email addresse here.

Enter your comment here

This form accepts SPIP shortcuts {{bold}} {italic} -*list [text->url] <quote> <code> and HTML code <q> <del> <ins>. To create paragraphs, just leave empty lines.

Add a document

Follow the comments: RSS 2.0 | Atom