Using pipelines

To use the pipelines of SPIP or of a plugin, their usage must be explicitly defined in the plugin.xml file:

<pipeline>
    <nom>name_of_the_pipeline</nom>
    <action>name of the function to load</action>
    <inclure>directory/file.php</inclure>
</pipeline>

The action parameter is optional, and by default, it has the same name as the pipeline. This declaration indicates a particular file to load when calling the pipeline (determined by the inclure) and loading a function like pluginprefix_action(). Note that the action parameter is only rarely provided.

Several pipelines can be specified by listing them as demonstrated below:

<pipeline>
    <nom>name_of_the_pipeline</nom>
    <inclure>directory/file.php</inclure>
</pipeline>
<pipeline>
    <nom>another_name</nom>
    <inclure>directory/file.php</inclure>
</pipeline>

Example

The pipeline insert_head adds content into the <head> section of published pages. The "Messagerie" plugin (using "messagerie" as a prefix) uses it for adding CSS styles:

<pipeline>
    <nom>insert_head</nom>
    <inclure>messagerie_pipelines.php</inclure>
</pipeline>

And in the messagerie_pipelines.php file:

function messagerie_insert_head($texte){
    $texte .= '<link rel="stylesheet" type="text/css" href="'.find_in_path('habillage/messagerie.css').'" media="all" />'."\n";
    return $texte;
}

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

Translations : English, français