Modifying all of your templates in one hit

Thanks to some special hooks, it is possible to use a single simple operation on a complete set of template files to modify the behaviour of a particular loop or type of loop, just by using the pre_boucle pipeline. For example, every RUBRIQUES loop, regardless of which template file it is stored in, can have sector 8 omitted from its search criteria:

  1. $GLOBALS['spip_pipeline']['pre_boucle'] .= '|hide_a_sector';
  3. function hide_a_sector($boucle){
  4. if ($boucle->type_requete == 'rubriques') {
  5. $secteur = $boucle->id_table . '.id_secteur';
  6. $boucle->where[] = array("'!='", "'$secteur'", "8");
  7. }
  8. return $boucle;
  9. }


Note that the plugin "Accès Restreint" also offers this function to restrict access to specific content.

Author Mark Baber Published : Updated : 02/06/10

Translations : English, français