Disclaimer: I am not a coder. I need to pull in a unique identifier for each Wiki page for use as a Javascript variable for a script in a customized Monobook skin (pre v1.16). 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. Can someone point me in the correct direction on how to pull in this value within the skin's PHP file itself? I'm not looking for an extension, etc. I need to make the changes directly in the skin.
Thanks for your assistance!
You may already have an OutputPage object, which is a context source. If so you can just do $out->getWikiPage()->getId();
On 29 July 2014 16:26, Grue Grue gruealta@gmail.com wrote:
Disclaimer: I am not a coder. I need to pull in a unique identifier for each Wiki page for use as a Javascript variable for a script in a customized Monobook skin (pre v1.16). 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. Can someone point me in the correct direction on how to pull in this value within the skin's PHP file itself? I'm not looking for an extension, etc. I need to make the changes directly in the skin.
Thanks for your assistance! _______________________________________________ MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
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@gmail.com wrote:
You may already have an OutputPage object, which is a context source. If so you can just do $out->getWikiPage()->getId();
On 29 July 2014 16:26, Grue Grue gruealta@gmail.com wrote:
Disclaimer: I am not a coder. I need to pull in a unique identifier for each Wiki page for use as a Javascript variable for a script in a customized Monobook skin (pre v1.16). 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. Can someone point me in the correct direction on how to pull in this value within the skin's PHP file itself? I'm not looking for an extension, etc. I need to make the changes directly in the skin.
Thanks for your assistance! _______________________________________________ MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
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@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@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.
On 29 July 2014 18:06, Kevin Israel pleasestand@live.com wrote:
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@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.
Yeah, not sure how I missed that bit. But we shouldn't be supporting anything other than 1.19.x, 1.22.x, and 1.23.x now.
Thanks for the explanation Kevin, your methods worked fine.
On Tue, Jul 29, 2014 at 12:06 PM, Kevin Israel pleasestand@live.com wrote:
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@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@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
MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org