Help talk:Magic words/Archive 001

Invoking tag without anonymous parameter
Hi, It look that invoking an XML-like extention with the #tag syntax but wihtout anonymous parameter is wrong. I made a test on the OpenStreetMap wiki (see ) with the folowing code and I got errors. But the following code (with an empty anonymous parameter) seems good (see ).

If the bug is from mediawiki, maybe it should be interresting to warn the users. FrViPofm 17:13, 31 August 2009 (UTC)


 * Why do you consider it a bug?


 * produces

< tagname parameter =" value "> content 
 * In your first example, you were sticking lat=47.2553 in as the content. Maybe it should be interesting to use it properly ^_^. Splarka 07:39, 1 September 2009 (UTC)
 * Because the syntax  is widely used for passing named parameters, it is strange to find it as anonymous parameter, and IMHO it is not consistent with the use of templates where we can find  FrViPofm 08:38, 1 September 2009 (UTC)
 * Well, it isn't "anonymous", it is just that the first parameter after the name is aways the content for #tag. Your use case happens to require it to be blank. That isn't buggy. Splarka 07:04, 2 September 2009 (UTC)

If I am not mistaken, this tag is no longer Expensive because of the schema changes made in 1.14 or 1.15. (Rob Church?)

If someone who knows better than I do agrees with my analysis, can you please remove that tag from the entry on this page?

Cheers!

--204.138.115.3 20:52, 3 September 2009 (UTC)

Request regarding urlencode
The old version on urlencode replaced spaces with underscores, however, a relatively recent change means that it now replaces spaces with plus signs. There is at least one (and I assume several) applications in which it is still necessary to have the underscore: when converting a string for use at http://stats.grok.se, underscores are required instead of spaces.

Therefore, is it possible for someone to create a new magic word called urlencode2 (or something similar)? This could process the subject string through urlencode, then change any instances of "+" to "_". If this is not the right place to request something like this, please direct me elsewhere. Thanks! --Zach425 19:11, 9 September 2009 (UTC)


 * Old version? relatively recent change? It looks like urlencode was introduced in 14273, only moved from Parser.php to CoreParserFunctions.php in 15276 where it has remained unchanged to this day. Where did you observe this change, Wikia perhaps? Splarka 07:10, 10 September 2009 (UTC)
 * Followup: here is the Help page on meta just a few weeks after it was introduced: . It shows  producing +x+y+%25%40. Splarka 07:23, 10 September 2009 (UTC)
 * You're absolutely correct - it seems I was MUCH mistaken regarding the "recent change". I'm sure I read that urlencode previously used an underscore instead of a plus sign (and its usage on Wikipedia suggests that this was indeed the case), but now I can't seem to find the site where I read that.
 * Urlencode aside, would it be possible to add rawurlencode as a magic word? I've found some documentation on it that indicates it would work for the problem stated above, as stats.grok.se accepts either _ or %20 in place of a space. Unfortunately, my very limited knowledge about PHP, Java, & MediaWiki doesn't allow me to act on what I've seen. Thanks again.  --Zach425 08:43, 10 September 2009 (UTC)
 * You can use the "escaped" version of the name-based magic words. For example: produces "", in a URL you can utilize it thusly: http://google.com/search?q= Splarka 13:26, 10 September 2009 (UTC)
 * THANK YOU, Splarka! This is just what I needed, but I unfortunately didn't understand FULLPAGENAMEE well enough to realize it! --Zach425 04:35, 11 September 2009 (UTC)

Using in a nested parser function
Sorry if this is a known workaround. I was unable to find it easily if it does exist out there somewhere.

I was running into a bit of a snag using the following parser function to evaluate whether a category should show a category tree or not (strictly a stopgap measure) at the top of the page.:

It seems that if there are more than 1000 pages in the category, fails because a comma is inserted into the number and the expression cannot parse it as a numerical value. The workaround here is to use the function:

RCWizard 23:12, 15 September 2009 (UTC)
 * You can just use NaN . That will also work on wikis set to a content language that delimits with periods, for example. Splarka 07:04, 16 September 2009 (UTC)

Why not REVISIONTIME?
Why not ? --Dvdgmz 15:53, 8 October 2009 (UTC)

PAGENAME, titleparts and categories
I'm trying to create a template that:


 * Auto-categorizes the including page
 * Sorts on the page name, but with a leading sub-page element stripped (e.g. "A/B/C" becomes "B/C")

What I have so far is something like:



This fails because of the inclusion/substitution order, but for the life of me, I can't get the right ordering of  and subst: that works for this. Can someone help me out, here and either point me to somewhere that #titleparts is used with PAGENAME in a template or show me an example that's otherwise known to work? Thanks. -Harmil 20:48, 12 October 2009 (UTC)

NUMBEROFACTIVEUSERS
Not much explanation on this - what is the definition of an active user? Based on number of edits / views? How recent? --Robinson Weijman 09:54, 10 November 2009 (UTC)


 * /includes/SiteStats.php


 * It scrapes the recent changes table, so this depends on your Manual:$wgRCMaxAge setting. Splarka 08:23, 11 November 2009 (UTC)
 * Thanks --Robinson Weijman 08:55, 22 January 2010 (UTC)

Comment about reverted edit
Happy-melon reverted this component
 * §§ and also see that page for information about substitution (subst:) of these parser functions. §§

What I was trying to indicate is that if one wants to substitute Magic words that one needs to follow the link to get instructions on how to undertake the task as they are not contained on the this page. Billinghurst 11:24, 3 December 2009 (UTC)
 * But that isn't where one should go to get those instructions; rather, one should look at Help:Substitution, which unfortunately hasn't yet been imported from meta. Happy ‑ melon 18:17, 3 December 2009 (UTC)
 * That may be right, but it isn't being helpful. I find it interesting (read: hard to understand) that there is a level of purity that means that rather than link to a page that has information of relevance, it is better to have no link at all. If the page needs to be imported, rather than just revert a link, how about getting said page imported. Billinghurst 07:58, 5 December 2009 (UTC)

Detail of sorting
(Reviving my unanswered question)
 * How does it sort pages that have the same sort key? PAGENAME? FULLPAGENAME? or something generally less useful, such as date of last edit? Robin Patterson 14:57, 21 July 2009 (UTC)

Robin Patterson 04:46, 1 January 2010 (UTC)

Is it normal that  displays the 53th week of 2009 when it's the 1st of 2010? JackPotte 19:32, 1 January 2010 (UTC)
 * Yes, 2009 contain 53 weeks.Crochet.david 16:51, 3 January 2010 (UTC)
 * So we should notify that respects the rule to change the 2nd week following the 1/01, unless of it's a Monday? JackPotte 18:24, 3 January 2010 (UTC)

Page name of transcluded page
Is there a way to automatically display the name of a page that has been transcluded into another page? If I use the or  magic words, I get the name of the page into which it has been transcluded. For example, if Example/subpage is transcluded into Example, they will show "Example", but what I want to display is "Example/subpage", so I can see what subpage is being used. Can this be done without hardcoding the name? RL0919 22:19, 23 February 2010 (UTC)
 * No; you'll need to hardcode the name into the subtemplate to get it to stay static. Happy ‑ melon 23:39, 23 February 2010 (UTC)
 * This JS code has been proposed as a gadget for that. JackPotte 21:57, 24 February 2010 (UTC)

Page name: keeping only the main title of the sub-page name
Hello. Is it possible to discard one part between brackets from a sub-page name, keeping only the main title? Example: keeping only “Foo” from “Title/Foo (bar)” Thanks. 200.163.4.66 14:59, 2 March 2010 (UTC)
 * Not really; you could hack something up with ParserFunctions and/or StringFunctions. Happy ‑ melon 23:12, 2 March 2010 (UTC)
 * OK

tagname
Can this page link to some explanation of what "tagname" means in the #tag: function? Better yet, a specific example? Wnt 09:44, 4 March 2010 (UTC)

PAGENAME for pages with underscore
The tz database contains identifiers containing an underscore. Templates, e.g. store data to make it accessible via includes.
 * en:Template:tz/country code
 * en:Template:tz/comments
 * en:Template:tz/coordinates

Works fine at But not at
 * Asia/Omsk
 * America/Santa_Isabel

Any magic word that can deliver the name with underscores, as in the URL?

TimeCurrency 00:33, 13 March 2010 (UTC)
 * Check the functions listed under Help:Magic words. Hamilton Abreu 01:32, 13 March 2010 (UTC)


 * I see nothing that would output "America/Santa_Isabel". I also tried whether would return its value - it does not. TimeCurrency 14:50, 13 March 2010 (UTC)


 * Misunderstood the question. Appending "E" to the magic word name should achieve the desired result:
 *   &rarr;
 *   &rarr;
 *   &rarr;
 *   &rarr;
 * Sorry about that. Hamilton Abreu 15:46, 13 March 2010 (UTC)

Great news, thank you. Also thank you for giving the list here. In fact I was thinking about PAGENAMEE, but Help:Magic_words says "URL-encoded" values, which is incorrect, details at en:URL encoding. But I don't with which words to correct this. TimeCurrency 02:39, 14 March 2010 (UTC)

NUMBEROFACTIVEUSERS
Hi - can anyone tell me how NUMBEROFACTIVEUSERS (= ) is defined? And can it be adjusted in e.g. LocalSettings? --Robinson Weijman 08:51, 15 March 2010 (UTC)
 * From what can be gathered in Release notes/1.15, it "is like NUMBEROFUSERS, but uses the active users data from site_stats." Special:Statistics indicates that it is registered users who have performed an action in the last 30 days. Hamilton Abreu 13:50, 15 March 2010 (UTC)


 * Aha, thanks Hamilton - very useful. --Robinson Weijman 12:53, 16 March 2010 (UTC)

can someone get #tag to work with the include tags?
I know #tag is supposed to work for extension XML tags, but can someone add support for, , , and  ? Thanks. Manishearth 02:21, 20 March 2010 (UTC)
 * . noinclude etc aren't handled the same way as other XML tags. Happy ‑ melon 18:41, 20 March 2010 (UTC)

CURRENTTIME family not affected by prefernces
No matter what I set my user preferences to, the CURRENTTIME family of magic words always seems to return UTC; both here and on my 1.15.1 local installation.

Is this a bug, a misdocumentation, or am I just doing it wrong? :) --WeaverThree 18:52, 23 March 2010 (UTC)


 * Page content does not change based on user preferences like that. It would invalidate cache horribly. Splarka 07:54, 24 March 2010 (UTC)


 * Yeah, I realized that after I went in there to see if I could "fix" it :). The only way it even seems possible would be if the parser left a marker in the output that say the skin code search-and-replaced with the proper value (since monobook.php appears to use user preference when adding the "last edited on" footer...?), and that just seems all kinds of messy-bad. Should the help just say "currenttime etc returns UTC time" then? --WeaverThree 12:47, 24 March 2010 (UTC)

Big redundancy
This page and its translations are to my mind to merge with meta:Help:Magic_words. JackPotte 11:21, 25 April 2010 (UTC)
 * Other way round. This is the master copy of the MediaWiki documentation (the one which will be kept up-to-date by the developers as the software changes); the content from meta should be merged here.  Happy ‑ melon 16:19, 25 April 2010 (UTC)
 * I agree but unfortunately I can't import them here with my user account and meta still hasn't got the same consensus. JackPotte 17:38, 25 April 2010 (UTC)

(SOLVED) Username
Is there any magic word which would username of return currently logged user?

Or his IP adress? --88.102.135.201 15:21, 18 May 2010 (UTC)
 * Check answer to Help_talk:Extension:ParserFunctions Hamilton Abreu 15:56, 18 May 2010 (UTC)


 * Well, that exactly what I didn't wanted. That writes name of who made last edit on such page, which is almost like signature. I need username of user who is just reading that page. --88.102.135.201 17:25, 18 May 2010 (UTC)
 * ...like for example for welcoming user by his name right on Main Page --88.102.135.201 17:48, 18 May 2010 (UTC)
 * I was looking for a MediaWiki-function like this, but I was told that there is none. But hey, if you find it - please tell me. :-) May be there is an extension which provides the username of the visiting user. I didn't check this, because installing an extension is no option at the wiki I was working on. -- Oculus Spectatoris  disputioe-mail 23:32, 18 May 2010 (UTC)

I think I found PHP variable, which contains username, however I wasn't able to create own Magic Word (not even normal static text). If you help me, I might be able to advance it into Magic Word containing username.. --88.102.135.201 00:12, 19 May 2010 (UTC)
 * So, using manual didn't helped me. However, I was able to tweak Extension:UserInfo and add this into it. However, it seems like these custom variables gets parsed and stored, as neither original variables or my experimantal one doesn't seem to react to logining as different user, change of browser... --88.102.135.201 01:23, 19 May 2010 (UTC)
 * Moreover, there is Extension:WhatIsMyIP, which is not installed on this Wiki. JackPotte 04:59, 19 May 2010 (UTC)
 * That might work, again I made it to show username. However, I cannot include special pages in other articles, including Main_Page, which means it doesn't really help. --88.102.135.201 09:15, 19 May 2010 (UTC)

I guess I know, why it didn't worked. PHP variable from which my experiments are fetching username is probably processed after parsing of document, which means it might not be ok...--88.102.135.201 10:43, 19 May 2010 (UTC)
 * This might be of no help either, but  Special:MyPage  &rarr; Special:MyPage takes you to the user's own user page. If you can figure out how that's done, therein might lie the answer. Hamilton Abreu 11:25, 19 May 2010 (UTC)
 * Most promising would be that Extension:WhatIsMyIP, I already managed to make it display current username correctly. However, if I try to treat that Special page as template and include it on normal page, it doesnt work. Only page I was able to include was Special:AllPages
 * Thats probably closest solution so far, I only need to include it. --88.102.135.201 11:54, 19 May 2010 (UTC)
 * Almost solved. class WhatIsMyIP extends SpecialPage { needed to be extended into class WhatIsMyIP extends IncludableSpecialPage {, now it almost works, username is correct, only thing I need is to get rid of line-breaks. --88.102.135.201 12:21, 19 May 2010 (UTC)

Okay, it seems like it still needs some work: There is a problem with OutputPage.php.

I can sort of include it on page, but if I want something more like IF or use it as part of link or such things, its doesn't work... :-( --88.102.135.201 13:56, 19 May 2010 (UTC)


 * Well, I finally managed to make it work. It took a bit of combining extensions, using magic words and special pages, molding it through styles and templates... but now I can process username with   or place it in link   . I tested it, any user I log in as different users, logged out.. tested from different computer.. process output with functions... fully working. If you are interested, I'll write a manual how to make it work. --88.102.135.201 11:24, 20 May 2010 (UTC)
 * Congratulations! :-) But... If I understand your report correct, then the result of your hard work is an extension that needs to be installed - which means it is on the first hand available for "private" operated wikis? Then you could nominate it at usability.wikimedia.org>Wikipedia Usability Initiative>Environment Survey to get it to the Foundation wikis too. Or is it just handful of code to improve the Mediawiki-software? Then it might be a good idea to look directly at the Developer hub here on Mediawiki. I'd like to use it someday! -- Oculus Spectatoris  disputioe-mail 15:20, 20 May 2010 (UTC)

Currently it is just bunch of manually upgraded extensions working together, I will refine it into something better and upload it, but I already have lot of other work ahead, so it might take a while. --88.102.135.201 16:27, 20 May 2010 (UTC)

List of Tables and Figures

 * 1) Is this the best place to ask for enhancements to Mediawiki magic words?
 * 2) Anyhow, could we please have   and   added for "list of tables" and "list of figures"? Maybe also ,  ,   for ToCs with tables or figures or both included and   for a common list of tables and figures. Crissov 12:30, 5 July 2010 (UTC)
 * No, this isn't the best place to ask for enhancements to Mediawiki magic words. The best place is mw:Project:Support_desk. When you edit this page you see a banner (the one that reads "Please do not post support questions here.") that tells you more about your options. ;-) Vale, Oculus Spectatoris  disputioe-mail 13:42, 5 July 2010 (UTC)
 * I saw that, but wasn't sure whether "support" covered enhancement request. — Christoph Päper 17:33, 5 July 2010 (UTC)

PAGESINCATEGORY doesn't work on my site.
I cannot seem to get the PAGESINCATEGORY magic word to work. My wiki treats it like its a Template.

Is there a setting that needs to be set somewhere to make it work? My Wiki Version is 1.13.1

I note that it works here: =
 * I can't help with your issue, but just to note that =  is wrong as there are (at present) 61 pages and 1 category. Is there a parameter to tell this function not to include categories? NinjaKid 20:48, 31 July 2010 (UTC)

DISPLAYTITLE
Something that isn't documented is the fact that works only in some namespaces (tested on 1.16.0).--188.109.252.74 12:06, 20 August 2010 (UTC)

Creator
Is there a variable where it shows who made the first edit (creator) of a particular page? Reh man  02:39, 24 December 2010 (UTC)
 * No, not at the moment in the core. Krinkle 13:16, 24 December 2010 (UTC)

Uploader
Is there a magic-word/template where it shows the uploader of a particular file? This would be most helpful when dealing with files, especially on Commons. Reh man  10:38, 8 January 2011 (UTC)

Transclusion
Please see
 * http://community.wikia.com/wiki/Forum:Need_history_link_that_works_in_Wiki-navigation

I tried clarifying the intro of Help:Magic Words.

"Page-dependent magic words will affect or return data about the current page (by default), even if the word is added through a transcluded template or included system message. For example; will always give the name of the page it is written on originally, even if displayed on other pages via transclusion."

I added the second sentence. The first sentence is really confusing. I am still not sure. Maybe Wikia is different. --Timeshifter 23:10, 26 January 2011 (UTC)

Number of days in a month
Could you please let me know if we have a magic word gives number of days in a month? Example this month (May) have 31 days. Thank in advance!--Cheers! 02:03, 14 May 2011 (UTC)

time of last revision
w:en:User:Omtay38/sandbox/Archive_10

Updated:

Updated:

Just granpa 02:45, 14 May 2011 (UTC)

Getting the username
Is there any way to detect the username of the person looking at a given page, so you could have the code respond "Greetings, " for example? This is a basic programming exercise, so I was surprised that there doesn't seem to be any documented way to do it with Mediawiki, unless I just haven't been looking in the right place.

I'd like to be able to make a welcome template that uses something like:
 * Yes, I am looking for the same thing, but for multiple other reasons.. I am looking for some kind of , I am also looking for some kind of

== Welcome! == {{post|1=0|2={{ subst: yoursig}}|3= May I extend my warmest welcomes and offer you any help you may need? Thanks for your {{NumberOfEdits|{{CurrentUser}}}} {{plural:contribution|{{NumberOfEdits|{{CurrentUser}}||s}}, {{gender:{{CurrentUser}}|Mr.|Ms.|}} {{CurrentUser}}!

If you need help with something...
 * ...I'm always available! You can drop a message on [[User_talk:{{{1}}}|{{gender:{{{1}}}|Mr.|Ms.|}} {{{2|{{{1}}}}}}'s user

talk page]] (which I watch like a hawk) or grab my other contact info on my [[User:{{{1}}}|{{gender:{{{1}}}|Mr.|Ms.|}} {{{2|{{{1}}}}}}'s user page]].
 * ...There's a wealth of wiki documentation on the meta wiki, perhaps some of it may be of use to you.
 * ...There's a really good Introduction over on meta also, it should help you figure out what's

going on if your new to wikis in general.

I'd like to hear a reply! Just click Edit above, and write a message under where mine ends - then, at the end of your message (on the same line) type four tildes (Like this: {{4tildes}}) to automatically insert a nickname linked to your user page, and a date/time signature!

Again, welcome to the wiki - and I can't thank you enough on behalf of the community for your help in making us the best DDO site around {{face|wink}}}} Technical 13 19:09, 22 June 2011 (UTC)
 * Which uses  {{Welcome|(Login of sysop)|(display name of sysop if different)}} 

does not affect title shown while previewing
This confused me for a bit because I thought I was doing something wrong -- the magic word only changes the title that is shown when viewing a page, not when editing. It would probably be a good idea to indicate this in the documentation.

What I'm wondering is: are there any other magic words for which this is true but not obvious?

--Woozle 23:26, 23 June 2011 (UTC)

counts sub-categories
Is there anyway to count only pages in a category, rather than pages and sub-categories? Eladkse 16:49, 11 July 2011 (UTC)

To report the server without reporting it as a link the following template can be used :

(remove space between "& #")

Useful for getting the server to be passed as a variable to java or object 188.222.137.154 10:36, 17 July 2011 (UTC)

Default user for gender tag
The gender tag should be enhanced to enable using the current username when none is provided. Otherwise, this tag is quite useless.

--DavidL 12:49, 30 September 2011 (UTC)

nowiki parameter in filepath
What is |nowiki parameter in supposed to do? Gustronico 16:33, 8 October 2011 (UTC)

Magic Word to reference Section Header Name
Is there any possibility to get the header name of the section - like as you can show the article name with  ? I am pretty sure I would have stumbled upon it if it was as easy as just using a magic word for it, but I could not even find an extension that provides it. I can't believe noone was in need for this before... Can anyone point me to something? Thanks a lot --Achimbode 16:04, 13 October 2011 (UTC)

Is magic variable expansion an atomic operation?
I cannot find it mentioned anywhere, hence the question: Is the expansion of mediawiki magic variables an atomic operation for the whole page? If so, is this "by accident/side-effect", or is MediaWiki deliberately coded to guarantee this under all circumstances (that is, also, if no caching is used)? I wonder, if the contents of variables could change during the time it takes to process a page.

To illustrate this, assume it would take some while to process a huge page containing a at the beginning and the end of the page. Will both magic variables be expanded to the same value, even if the second rolls over in the meantime?

The background to the question is the observation, that various Wikipedia templates use the 2024, August , 27 , and similar MediaWiki variables to compose more complex date representations for a multitude of purposes. Example for a template to display the ISO 8601 date:

2024-August-

Now, if MediaWiki would not guarantee that all these variables do not change while the template is being processed, such a template would produce faulty output if executed in the very moment, when the month rolls over. In this moment, it could still output the old month (and year), but the new date. Example: If 2011-11-30 rolls over to 2011-12-01, the template might emit 2011-11-01 instead. If 2011-12-31 rolls over to 2012-01-01, the template might emit 2011-12-01 or 2011-01-01 instead.

It would be possible to create the same ISO 8601 output by processing the contents of the variable instead, however, this is more complicated to code, and most of the existing templates to do take this route. So, do all these templates just work "by accident" (since the rollover is a relatively rare event) or does the MediaWiki variable expansion takes care of this by design? Thanks. --88.77.205.254 18:16, 7 November 2011 (UTC)


 * All of them are replaced with the same timestamp, provided by ParserOptions::getTimestamp, so there won't be such rollover effect. Platonides 18:50, 7 November 2011 (UTC)


 * Thank you for the quick answer. --84.63.108.166 19:54, 7 November 2011 (UTC)