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
 * http://en.wikipedia.org/wiki/Asia/Omsk
 * http://en.wikipedia.org/wiki/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)