-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Ittay Dror wrote:
I see two addHeadItems:
includes/OutputPage.php: function addHeadItem( $name, $value ) { includes/ParserOutput.php: function addHeadItem( $section, $tag = false ) {
which one should i use?
The one on the output of the parser object that was passed to your hook. This will record it in the parser cache record for later output.
I'm not sure this is the most stable api ever, though, it feels a little weird to me. :) But here's an example in the SyntaxHighlight_GeSHi extension:
$parser->mOutput->addHeadItem( "<style type="text/css">/*<![CDATA[*/\n" . ".source-$lang {line-height: normal;}\n" . ".source-$lang li {line-height: normal;}\n" . $geshi->get_stylesheet( false ) . "/*]]>*/</style>\n$sitecss", "source-$lang" );
The first parameter is the actual HTML fragment you want to output.
The second is optional, and is a section keyword which should be unique to your extension -- if you try to add two head sections with the same key, only the last one will be output.
This avoids duplicate output when your hook is used more than once in the same page. You should be sure that they really will be equivalent in this case; if you output something different on each call, maybe you do want to output it multiple times.
- -- brion vibber (brion @ wikimedia.org)