On 07/29/2014 11:43 AM, Alex Monk wrote:
Argh. Apparently ctrl+enter sends the message, whoops.
Anyway, otherwise
you can use RequestContext::getMain()->getWikiPage()->getId();
On 29 July 2014 16:42, Alex Monk <krenair(a)gmail.com> wrote:
> You may already have an OutputPage object, which is a context source. If
> so you can just do $out->getWikiPage()->getId();
RequestContext and WikiPage were added in MW 1.18, so they won't be
available in the (very old, no longer supported) "pre v1.16" version
stated in the question.
In pre-1.18 versions, use $wgTitle->getArticleId() (with global
$wgTitle; in the function). However, in the skin's QuickTemplate
subclass, you can use $this->data['articleid'] (no global statement needed).
Do note that if you only need to use the value in JavaScript code, you
shouldn't have to change the skin's PHP code. The variables documented
in Manual:Interface/JavaScript as available in your MW version should
already work (e.g. alert(wgArticleId); should show the value in a dialog
box unless your MW version is older than 1.8).
> On 29 July 2014 16:26, Grue Grue
<gruealta(a)gmail.com> wrote:
>
>> [...] wgArticleId seems to be the perfect
>> way to do so, as it does not change with redirects and is not defined for
>> deleted or special pages.
It may change when a page is deleted and undeleted. Also, it is not
undefined for non-existent and special pages but rather zero.
--
Kevin Israel - MediaWiki developer, Wikipedia editor
http://en.wikipedia.org/wiki/User:PleaseStand