Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > insert_head

insert_head

The insert_head pipeline adds some content into the <head> section of an HTML page:

  • wherever the #INSERT_HEAD tag has been used,
  • otherwise just before </head> if the function f_insert_head is called in the affichage_final pipeline - for example with this line in mes_options.php :
  1. $spip_pipeline['affichage_final'] .= '|f_insert_head';

The pipeline accepts the contents to be added as arguments and returns the completed contents:

  1. function prefixPlugin_insert_head($flux){
  2. $flux .= "<!-- A comment that does nothing ! -->\n";
  3. return $flux;
  4. }

Download

Example

Add in a jQuery function call, in this case, to display a toolbar for textarea tags in the Crayons forms (with the plugin "Porte Plume"):

  1. function documentation_insert_head($flux){
  2. $flux .= <<<EOF
  3. <script type="text/javascript">
  4. <!--
  5. (function($){
  6. $(document).ready(function(){
  7. /* Add a porte plume toolbar into crayons */
  8. function barrebouilles_crayons(){
  9. $('.formulaire_crayon textarea.crayon-active').barre_outils('edition');
  10. }
  11. barrebouilles_crayons();
  12. onAjaxLoad(barrebouilles_crayons);
  13. });
  14. })(jQuery);
  15. -->
  16. </script>
  17. EOF;
  18. return $flux;
  19. }

Download

The onAjaxLoad JavaScript function is used here to provide the given function as a parameter during the AJAX load of a page element.