Fandom

Community Central

Admin Forum:wg Variables

19,031pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

This Forum has been archived

Forums: Admin Central Index Technical Help Wg Variables
Wikia's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.


Hi. I've got a question relating to the MW 1.19 upgrade: Can we still use the same wg variables as on MW 1.16 wikis? I'm not very knowledgeable about the use of JavaScript, but I have a few global scripts that could be severely affected by Wikia dropping the the use of, for example: $wgServer, $wgAction etc. What has really spurred me into action is that I noticed, in the source of a MW 1.19 wiki, that those two (and more) don't seem to exist any longer — or did I miss a link? :) Starfleet Academy (Messages) 09:11, September 4, 2012 (UTC)

The wg* variables were deprecated in MW 1.17 and you shouldn't use them unless you need your code to run on 1.16 Wiki. Documentation. They currently work on MW1.19 because Wikia has thrown the "use globals" switch but it'll break when that switch is turned off. The correct way to access them is: mw.config.get('wgServer'). Lunarity 19:57, September 4, 2012 (UTC)
Thanks, Lunarity! You've informed me of my worst fears! Wow, I'm gonna have to do some reading about objects and jQuery... or I'm going to have to learn full JS pretty darn quick. :P Thanks again (because this will force me to cram!). :) Starfleet Academy (Messages) 03:15, September 5, 2012 (UTC)
Hey, I'm back again with another question: Is my Global JS file going to be okay now, if the 'switch' is thrown? :) Starfleet Academy (Messages) 09:24, September 6, 2012 (UTC)

Sort of. That'll crash on MW1.16 so you'll need to add:

(window.mw = window.mw || {}).config = window.mw.config || { get: function(p) { return window[p]; } };

At the start. Lunarity 05:49, September 7, 2012 (UTC)

Thanks for all your help, mate. The code above works great! :D Starfleet Academy (Messages) 08:30, September 7, 2012 (UTC)

Also on Fandom

Random Wiki