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
:
$spip_pipeline['affichage_final'] .= '|f_insert_head';
The pipeline accepts the contents to be added as arguments and returns the completed contents:
function prefixPlugin_insert_head($flux){
$flux .= "<!-- A comment that does nothing ! -->\n";
return $flux;
}
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"):
function documentation_insert_head($flux){
$flux .= <<<EOF
<script type="text/javascript">
<!--
(function($){
$(document).ready(function(){
/* Add a porte plume toolbar into crayons */
function barrebouilles_crayons(){
$('.formulaire_crayon textarea.crayon-active').barre_outils('edition');
}
barrebouilles_crayons();
onAjaxLoad(barrebouilles_crayons);
});
})(jQuery);
-->
</script>
EOF;
return $flux;
}
The onAjaxLoad
JavaScript function is used here to provide the given function as a parameter during the AJAX load of a page element.