Help talk:Magic words

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
WikiProject iconWikipedia Help NA‑class Low‑importance
WikiProject iconThis page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the Help Menu or Help Directory. Or ask for help on your talk page and a volunteer will visit you there.
NAThis page does not require a rating on the project's quality scale.
LowThis page has been rated as Low-importance on the project's importance scale.

Current Year[edit]

How to use in a redirect?. For example,

#redirect [[United Nations Climate Change conference#{{CURRENTYEAR}}]]

to go to the current year section in the UNCCC article?:

United Nations Climate Change conference#2022


--BoldLuis (talk) 10:48, 17 May 2022 (UTC)[reply]

@BoldLuis redirects (and articles in general) shouldn't use dynamic values, because the cached copy of the page will "stick" on the old version. — xaosflux Talk 13:06, 17 May 2022 (UTC)[reply]
Thank you. Really, it is a trouble to overcome by Wikipedia / MediaWiki . BoldLuis (talk) 13:50, 24 May 2022 (UTC)[reply]

Showing the user viewing the page[edit]

Help:Magic_words#cite_note-2 reads "There is no way to show the user viewing the page due to technical restrictions.". Actually, with a bit of JavaScript, it can be done. For non-JS and non-logged-in users, the HTML template can contain something generic, e.g.:

Welcome, <span class=username_placeholder>Wikipedian</span>!
if (mw.config.values.wgUserName) /* to only run code if the user is logged in */ {
	for (count=0; count < document.getElementsByClassName("username_placeholder").length; count++) {
		document.getElementsByClassName("username_placeholder")[count].innerHTML = mw.config.values.wgUserName;
	}
}

EstherLoer 00:13, 26 May 2022 (UTC)[reply]

Well sure, but this is a page about magic words, which can't do this themselves, I added that to the note. — xaosflux Talk 01:45, 26 May 2022 (UTC)[reply]

Established consensus on where to place magic words?[edit]

I’ve done a brief read of this page, Help:Magic words for beginners, and a few of the variables’ documentations, but I can’t find much of an inclination as to where each of the magic words should be placed on a page. While a few of them would fall under WP:COMMONSENSE, I can’t help but wonder if there is consensus on the matter. — Mugtheboss (talk) 16:56, 13 September 2023 (UTC)[reply]

It depends on the situation and the magic words in question.
Which ones were you thinking of? - jc37 19:21, 13 September 2023 (UTC)[reply]
All of them as a whole, I’m thinking that it would be good if there was a section in one of the two pages that describes where to place each one. — Mugtheboss (talk) 07:32, 14 September 2023 (UTC)[reply]
It doesn't make sense to recommend placement on a page for all of the magic words. There is no recommended place to put {{CURRENTHOUR}}, for example. It is used where it is needed. – Jonesey95 (talk) 15:41, 14 September 2023 (UTC)[reply]
{{CURRENTHOUR}} would be one of those examples that falls under WP:COMMONSENSE as the output is in UTC, but what about something like {{SITENAME}}? Everyone knows what site we’re on, and in the majority of instances, it’s faster to type it out. What about {{formatnum}}/{{formatnum|R}}? There’s no immediate use for these that springs to mind other than automated edits by bots.
I was originally drawn to this page because I found an article (I can’t remember which) with {{DISPLAYTITLE}} at the end of the lead, and it was creating an ugly extra line. I came to the aforementioned pages to find guidance on if I could move it to mitigate the issue, and got no help. It would make sense to educate people on how magic words are responsibly placed to open more avenues for editors — it would be irritating for me, you, or another editor to place hundreds of magic words, just to realise they were all placed wrong. — Mugtheboss (talk) 21:04, 14 September 2023 (UTC)[reply]
WP:ORDER explains where to put SHORTDESC, DISPLAYTITLE, magic words related to ToC, and DEFAULTSORT. —⁠andrybak (talk) 23:19, 14 September 2023 (UTC)[reply]
I meant to link to WP:ORDER from this section earlier. I have added a short note to the lead of this page, along with a link. – Jonesey95 (talk) 00:39, 15 September 2023 (UTC)[reply]
I completely forgot that WP:ORDER explains where DISPLAYTITLE should be placed. trout Self-trout. — Mugtheboss (talk) 08:48, 15 September 2023 (UTC)[reply]
I have now found the page and fixed the issue. — Mugtheboss (talk) 08:58, 15 September 2023 (UTC)[reply]

Forcing evaluation of the Magic Words.[edit]

Is there any way that I can add {{CURRENTYEAR}} to the text of a page and have the actual text stored being the evaluation of the magic word, so 2024 ends up in the text.Naraht (talk) 22:02, 17 February 2024 (UTC)[reply]

@Naraht: Yes: {{subst:CURRENTYEAR}} yields 2024. -- John of Reading (talk) 08:25, 18 February 2024 (UTC)[reply]