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:

$GLOBALS['spip_pipeline']['pre_boucle'] .= '|hide_a_sector';

function hide_a_sector($boucle){
  if ($boucle->type_requete == 'rubriques') {
    $secteur = $boucle->id_table . '.id_secteur';
    $boucle->where[] = array("'!='", "'$secteur'", "8");
  }
  return $boucle;
}

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