Using pipelines

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

  1. <pipeline>
  2. <nom>name_of_the_pipeline</nom>
  3. <action>name of the function to load</action>
  4. <inclure>directory/file.php</inclure>
  5. </pipeline>

Download

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:

  1. <pipeline>
  2. <nom>name_of_the_pipeline</nom>
  3. <inclure>directory/file.php</inclure>
  4. </pipeline>
  5. <pipeline>
  6. <nom>another_name</nom>
  7. <inclure>directory/file.php</inclure>
  8. </pipeline>

Download

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:

  1. <pipeline>
  2. <nom>insert_head</nom>
  3. <inclure>messagerie_pipelines.php</inclure>
  4. </pipeline>

Download

And in the messagerie_pipelines.php file:

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

Download

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

Translations : English, français