Jump to content

Help talk:Magic words

Add topic
From mediawiki.org
Latest comment: 2 months ago by Shirayuki in topic Wrong markup

WBREPONAME not mentioned

[edit]

{{WBREPONAME}} and possibly many other Magic words are not mentioned here. For example, en:MediaWiki:Exceeded-entity-limit-category reads Pages with too many {{WBREPONAME}} entities accessed. {{WBREPONAME}} produces Wikidata. Even though these magic words might not be widely used, I think all of them should be properly documented here. —‍CX Zoom (A/अ/অ) (let's talk|contribs) 20:15, 6 January 2025 (UTC)Reply

This page is only for magic words provided by MediaWiki core, not extensions. * Pppery * it has begun 20:40, 6 January 2025 (UTC)Reply
Oh, I understand now. Thanks! —‍CX Zoom (A/अ/অ) (let's talk|contribs) 20:47, 6 January 2025 (UTC)Reply

How to use #tag to show attributes that have no values?

[edit]

I can use

{{#tag:syntaxhighlight|<b>test code</b>|lang="wikitext"}}

to render a syntaxhighlight tag like this:

<b>test code</b>

How can I use the same syntax to include the "inline" attribute, which takes no parameter value? Jonesey95 (talk) 00:50, 21 March 2025 (UTC)Reply

Don't know if there is a rule for this, but at least inline="" works, because it is created by Visual Editor. Looks like inline= works too, but I'm not sure it's always the case. IKhitron (talk) 11:50, 21 March 2025 (UTC)Reply

NAMESPACENUMBER

[edit]

{{NAMESPACENUMBER: <any namespace> }} always returns 0. ([1]) - Erik Baas (talk) 14:58, 12 August 2025 (UTC)Reply

I think you meant to link to Help:Magic words#Namespaces. (Help:Magic words#Namespaces_2 is about {{ns:…}}.) In any case, the argument to {{NAMESPACENUMBER:…}} is a page name, not the name of a namespace. So, for example: {{NAMESPACENUMBER:{{FULLPAGENAME}}}} returns 13, because this page (Help_talk:Magic_words) is in the Help_talk namespace, which is ns 13. - dcljr (talk) 08:11, 14 August 2025 (UTC)Reply
I must have misread the example {{NAMESPACENUMBER:MediaWiki}}, assuming "MediaWiki" meant the namespace of that name. Thank you. - Erik Baas (talk) 19:13, 14 August 2025 (UTC)Reply
I've changed the example to prevent just this sort of confusion (now uses "Main Page", which on this wiki just happens to be equivalent to "MediaWiki"). - dcljr (talk) 21:49, 26 August 2025 (UTC)Reply
Great, thank you. - Erik Baas (talk) Erik Baas (talk) 00:45, 27 August 2025 (UTC)Reply

var

[edit]

Google's AI Overview seems to think there's a thing called {{#var:…}} in MediaWiki — more specifically, {{#var:skin}}, which would return something like "Vector" or "MonoBook". (I found this by searching for "how to detect which skin a user is using in a mediawiki template".) This doesn't seem to be a thing on any WM wiki I've tried it on. Does anyone know where Google's AI Overview got that idea? Is there an extension that provides that functionality? (Or if anyone knows the answer to my original search question, that would also be appreicated. Specifically, I would like to know how to distinguish between legacy Vector and Vector 2022.) - dcljr (talk) 08:01, 14 August 2025 (UTC)Reply

{{#var:…}} comes from Extension:Variables, but its documentation doesn’t mention any predefined variables (and it’s not installed on WMF wikis anyway). At least on WMF wikis, AFAIK there’s no way to get the ID of the current skin, but you can use Extension:TemplateStyles with the body.skin-vector-2022 / body.skin-vector-legacy selector to tell them apart – TemplateStyles is not nearly as powerful as a variable would be, but you can restyle or hide things based on the skin, which should be enough for most cases. —Tacsipacsi (talk) 23:27, 14 August 2025 (UTC)Reply

Suggestion: Two new Magic Words: PAGESONPAGE and ARTICLESONPAGE

[edit]

For the sake of reports and other possible uses, I created a wish on the Community Wishlist to add the Magic Words PAGESONPAGE and ARTICLESONPAGE (both falling in the category of Statistics), that would return the number of unique links to pages and articles (subset of pages) that are on a page. I welcome your comments in the wish's Discussion page. StefenTower (talk) 08:24, 16 August 2025 (UTC)Reply

Wrong markup

[edit]

What was wrong with markup [2] @Shirayuki? Waddie96 (talk) 10:25, 6 September 2025 (UTC)Reply

@Waddie96: The Translate extension outputs ‎<span>...‎</span> (or ‎<div>...‎</div>) tags for untranslated or fuzzy translation units on translation pages. However, since those tags contain equal signs in their attribute parts, the part before the equal sign is misinterpreted as a parameter name, causing them to not display at all. Therefore, when using ‎<translate> in a parameter, we must explicitly specify the parameter name, such as 1= or 2=. -- Shirayuki (talk) 10:36, 6 September 2025 (UTC)Reply