Hello, all.
I've always been a big fan of Mediawiki and of free software in general, but one thing I struggle with in extending the wiki I work on is adding adding code to the the head of the HTML. ResourceLoader may be terrific from a performance perspective, but it is an absolute nightmare for this small scale developer. I'm a self-taught programmer, and my eyes just glaze over when I look at the documentation. Yet it is something that I often need to do, for Google Analytics, Google Custom Search, to make a custom media player (that does what I want it to do), etc.
I'm looking for a short snippet of code - just something that I can paste into LocalSettings.php that will take the contents of specific variable and paste it into the head of every HTML page on the wiki. That's it.
I bet it could be done in 10 lines of code and it would be so helpful for our site. Yet I'm sure it would take me 5 very frustrating hours for me to figure it out, as I find some of the documentation quite opaque. Would anyone be willing to program this? I'm happy to pay consulting fees. If you want to give it away for free after, more power to you.
Forest
I had the same problem as you when I was trying to simply add JavaScript to the head of all pages. All the ResourceLoader related things I tried either didn't work or merely added it at the end of a document or as a deferred load which didn't work for my purpose. What I ended up doing was modifying our custom extension the following:
$wgHooks['BeforePageDisplay'][] = 'UESP_beforePageDisplay';
function my_beforePageDisplay( &$out ) { global $wgScriptPath;
$out->addHeadItem("uesp", "<script src='$wgScriptPath/somepath/script.js'></script>"); return true; }
which works well enough. I assume you could add this to LocalSettings.php instead and it would work. Perhaps someone else can tell us if there's a "better" way of doing something like this....
On 27 May 2013 18:19, Forest S forest@tmswiki.org wrote:
Hello, all.
I've always been a big fan of Mediawiki and of free software in general, but one thing I struggle with in extending the wiki I work on is adding adding code to the the head of the HTML. ResourceLoader may be terrific from a performance perspective, but it is an absolute nightmare for this small scale developer. I'm a self-taught programmer, and my eyes just glaze over when I look at the documentation. Yet it is something that I often need to do, for Google Analytics, Google Custom Search, to make a custom media player (that does what I want it to do), etc.
I'm looking for a short snippet of code - just something that I can paste into LocalSettings.php that will take the contents of specific variable and paste it into the head of every HTML page on the wiki. That's it.
I bet it could be done in 10 lines of code and it would be so helpful for our site. Yet I'm sure it would take me 5 very frustrating hours for me to figure it out, as I find some of the documentation quite opaque. Would anyone be willing to program this? I'm happy to pay consulting fees. If you want to give it away for free after, more power to you.
Forest _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org