Page MenuHomePhabricator

add exposed JS wgRevisionId as a magic word
Closed, DeclinedPublic

Description

Hello .. I'm using Extension:Approved Revisions [1] and I have a need to be able to display the revision ID of the page revision currently being viewed. From the MW Manual page on Javascript [2] I see that the variable "wgRevisionId" contains this information and is exposed to mediawiki for use, but it is not clear to me how to do so. I would like to create a "magic word" [3] called <code>{{VIEWEDREVID}}</code> that outputs the revision ID of the revision being viewed such that it can be used in other parser logic

For example:

{{#ifexpr:( {{VIEWEDREVID}} < {{APPROVEDREVID}} )
|if true
|if false
}}

Can this feature be added to Approved Revisions, please. (Is it already somehow?)

Thank you!
-Rich [[User:revansx]]

[1] https://www.mediawiki.org/wiki/Extension:Approved_Revs
[2] https://www.mediawiki.org/wiki/Manual:Interface/JavaScript
[3] https://www.mediawiki.org/wiki/Help:Magic_words

Event Timeline

Do you want APPROVEDREVID or VIEWEDREVID?

To get the revisionid of the shown revision you can use {{REVISIONID}}. It should be equal to the js variable. If not, the extension may handle this kind other and that sounds like a bug.

Hi Umherirrender,

HexMode explained to me that placing the revision id of the revision that the user is presently viewing (rather than simply the latest) would actually break the whole caching systems. He helped me realize that what I'm trying to do is best done in Mediawiki:Common.js. That said, I was able to write a simple JS line like this:

document.getElementById('MyDiv001').innerHTML = mw.config.get('wgRevisionId');

in Mediawiki:Common.js and get the information I needed into a wiki article. Cool!

Yaron_Koren subscribed.

Marking this as "Declined"... I hope that's okay.