Wikia

Community Central

Admin Forum:Javascript's equivalent to magic words and transclusion

18,700pages on
this wiki
Talk0

This Forum has been archived

Forums: Admin Central Index Technical Help Javascript's equivalent to magic words and transclusion
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.
Note: This topic has been unedited for 1290 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.



I was wondering if there's any way to transclude pages using javascript, for example, to display a short page into the siderail. That way I can edit the page normally without having to touch the code too many times (the js caching is slow.)

It would also be glad if someone can point me the equivalent to magic words, for example:
{{REVISIONID}}
or
{{NUMBEROFARTICLES}}
in javascript, I knew there's a list to all the variables somewhere. I'm very new to JS. Any help would be appreciated! --Mfaizsyahmi (talk) 21:28, April 7, 2012 (UTC)
There is a list of JavaScript variables included with every page that give you lots of useful information - the revision ID (wgCurRevisionId) being one of them. But you will not find a corresponding variable for each and every magic word (and vice versa). The number of articles e.g. is not so easily available. If you've just started to learn JavaScript then I hope you've already figured out that JavaScript runs in the client while all of these magic words are expanded on the server. It's the server that creates and fills all the JavaScript variables you see in the page's source code and it's the server you will have to contact with JavaScript to find out the more elusive stuff. The MediaWiki software provides an extensive API you can query with JavaScript and jQuery provides a handy method to just that end. But this is advanced stuff and I'm not sure it will be of much use to a beginner at JS. In all honesty: I would recommend to start with something much simpler. --  pecoes  05:16, April 11, 2012 (UTC) 
I'll lay these advanced topics for later then. Thanks for replying! --Mfaizsyahmi (talk) 12:31, April 11, 2012 (UTC)
p.s. Another topic ripe to be sunken to the bottom of the forum.

Around Wikia's network

Random Wiki