Definition

A pipeline is used to make one of SPIP’s standard functions perform different or additional functionality by passing it custom-made functions that will be automatically triggered at the right times.

Declaration within a plugin

Any plugin can use any existing pipeline. To do so, it declares it in the plugin.xml file as illustrated here below:

<pipeline>
   <nom>header_prive</nom>
   <inclure>cfg_pipeline.php</inclure>
</pipeline>
  • Nom: specifies the name of the pipeline to be used,
  • Inclure: specifies the name of the file that contains the function to be executed when the pipeline is called (prefixPlugin_PipelineName()).

Declaration without using a plugin

One usage of a pipeline outside that of plugins does remain possible. In this case, it must be declared directly in the config/mes_options.php file:

$GLOBALS['spip_pipeline']['name_of_the_pipeline'] .= "|name_of_the_function";
// Example of adding into the "insert_head" pipeline:
$GLOBALS['spip_pipeline']['insert_head'] .= "|name_of_the_function";
 
function name_of_the_function($flux) {
	return $flux .= "This text will be appended";
}

The function called must be declared already at the time that the pipeline is called, with the simplest solution being to declare it as above with a name_of_the_function function defined in the options file.

Note that SPIP uses a cache of the pipelines used, and that any new declaration will require this cache to be refreshed. This can be done by navigating to the "Plugin management" page in the private zone (?exec=admin_plugin).

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français