I want to add an external script to the main section for all pages in mediawiki.
Function onBeforePageDisplay callback BeforePageDisplay hook:
//LocalSettings.php ... # Assign my functions to hook $wgHooks['BeforePageDisplay'][] ='onBeforePageDisplay'; function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) { mw.loader.load('http://static.wowhead.com/widgets/power.js', 'text/javascript'); $out->addModules( 'mw.loader' ); return true; };
In this function I want to add
<script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script> <script>var wowhead_tooltips = { "colorlinks": true, "iconizelinks": true, "renamelinks": true }</script>
to <head> for all pages in the wiki.
For older versions of mediawiki, the addScript OutputPage object method is used :
$out->addScript( $html )
but now
For MediaWiki 1.17 and higher, use the ResourceLoader modules.
$ out-> addModules (array (/ modules /));
I could not get it to work and did not find examples of this.
Description of ResourceLoader
Description of Default_modules
Maybe I need to use the mw.loader.load module, but I have no idea how to do this. Please help me and sorry for my English.
Ps this one works, but itβs not right. Need a solution using ResourseLoader. (C) IMHO