I'm working on a new extension, and it adds quite a bit of new CSS and Javascript. Other than hacking MonoBook.php, is there an easy way for me to add stuff into the headers? I can't seem to find any hooks that do this...
Thanks,
Ryan Lane
Am Mittwoch 27 Dezember 2006 15:21 schrieb Lane, Ryan:
I'm working on a new extension, and it adds quite a bit of new CSS and Javascript. Other than hacking MonoBook.php, is there an easy way for me to add stuff into the headers? I can't seem to find any hooks that do this...
This is what the SelectCategory extension does:
<code> $wgHooks['OutputPageParserOutput'][] = 'fnSelectCategoryOutputHook';
## Entry point for the hook for printing the CSS: function fnSelectCategoryOutputHook( &$m_pageObj, &$m_parserOutput ) { global $wgScriptPath;
# Register CSS file for our select box: $m_pageObj->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'href' => $wgScriptPath . '/extensions/SelectCategory/SelectCategory.css' ) );
# Be nice: return true; } </code>
Not sure if that's the best way, though, since that would cause another http request per unique user.
-- Leon
This is what the SelectCategory extension does:
<code> $wgHooks['OutputPageParserOutput'][] = 'fnSelectCategoryOutputHook';
## Entry point for the hook for printing the CSS: function fnSelectCategoryOutputHook( &$m_pageObj, &$m_parserOutput ) { global $wgScriptPath;
# Register CSS file for our select box: $m_pageObj->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'href' =>$wgScriptPath . '/extensions/SelectCategory/SelectCategory.css' ) );
# Be nice: return true;}
</code>
Not sure if that's the best way, though, since that would cause another http request per unique user.
-- Leon
Hey, looks like that works. Thanks for the tip. Unfortunately the hook is only available in mediawiki 1.8+, but I'll take what I can get ;).
V/r.
Ryan Lane
This is what the SelectCategory extension does:
<code> $wgHooks['OutputPageParserOutput'][] = 'fnSelectCategoryOutputHook';
## Entry point for the hook for printing the CSS: function fnSelectCategoryOutputHook( &$m_pageObj,
&$m_parserOutput ) {
global $wgScriptPath; # Register CSS file for our select box: $m_pageObj->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'href' =>$wgScriptPath . '/extensions/SelectCategory/SelectCategory.css' ) );
# Be nice: return true;}
</code>
Not sure if that's the best way, though, since that would cause another http request per unique user.
-- Leon
Hey, looks like that works. Thanks for the tip. Unfortunately the hook is only available in mediawiki 1.8+, but I'll take what I can get ;).
V/r.
Ryan Lane
Argh, I spoke too soon. This only seems to work when the parser cache is purged. The "OutputPageBeforeHTML" does work though. Unfortunately, this hook looks like it is broken in a number of ways.
Is there a good place to add a hook for this specific type of functionality? I've put one in OutputPage.php in the output() function above the section where the ajax javascript is added to the headers, and it seems to work for regular page views, and during previews. Unfortunately, I'm not sure exactly how this could affect other things.
Any ideas?
V/r,
Ryan Lane
On 28/12/06, Lane, Ryan Ryan.Lane@ocean.navo.navy.mil wrote:
Is there a good place to add a hook for this specific type of functionality? I've put one in OutputPage.php in the output() function above the section where the ajax javascript is added to the headers, and it seems to work for regular page views, and during previews. Unfortunately, I'm not sure exactly how this could affect other things.
ProfileMonitor uses the SkinTemplateSetupPageCss hook. This seems to exist from 1.6.0 upwards. The extension is in Subversion.
Rob Church
ProfileMonitor uses the SkinTemplateSetupPageCss hook. This seems to exist from 1.6.0 upwards. The extension is in Subversion.
Rob Church
I need to output css and javascript, and this one only outputs css. It did however lead me in the right direction. "BeforePageDisplay" in SkinTemplate.php is available in 1.7+ and the comments say it is specifically there to allow extensions to add css and javascript. I'll update mediawiki.org's hooks list so this is easier for the next person.
Thanks for the help everyone!
V/r,
Ryan Lane
wikitech-l@lists.wikimedia.org