Help talk:Extension:ParserFunctions/2014-2020

#time: and Daylight Savings
Is there any flag for DST? Is there any intent to add a flag for this in the future if it currently doesn't exist? Thank you. -- ShoeMaker  ( Contributions &bull; Message )   18:30, 9 November 2012 (UTC)

Square root and other questions
Hello,

I had 2 questions about the &#123;&#123;#expr:}} and the &#123;&#123;#ifexpr:}} parser functions: 80.230.37.167 14:38, 26 November 2012 (UTC)
 * 1) Is it possible to add a square root to those functions? using the sign √ in a formula doesnt work to me.
 * 2) Also, what do the != and the <> logic keys do?
 * Oh, i see that != make negative solutions possitive, but i still need the square root thing.
 * 80.230.37.167 14:49, 26 November 2012 (UTC)
 * ! in front of any conditional punctuation means NOT, so != is NOT EQUAL. As far as your question about sqr roots, you could build a (set of) template(s) like http://meta.wikimedia.org/wiki/Template:Root -- 141.114.97.70 15:08, 26 November 2012 (UTC)
 * tHANK YOU 80.230.37.167 15:59, 26 November 2012 (UTC)
 * That template does not work. sqrt is not recognized. How can I get a square root calculation?
 * King Dragonhoff 12 December 2014
 * Templates were never supposed to be some kind of "programming language", and the whole idea of Tim Starling's parser functions was to offer a faster alternative to template hacks ignoring this rule. State of the art is to use Scribunto math in the module namespace, if the parser functions are not good enough for your purposes. –Be..anyone (talk) 00:36, 13 December 2014 (UTC)
 * I created this template. It can find any root of a number.
 * King Dragonhoff 27 February 2015
 * Write the root as an exponential power:  =  . Or, in general,   for the  -th root of  . --Theaitetos (talk) 22:06, 27 February 2015 (UTC)

#time and full month names
Hi, I am apparently not seeing any indication of what any underlying support files are called.

The F operator returns a full month name, so 12 produces "December".

Which file houses the actual "December" string?

At my home wiki, it is returning the wrong string.

Thanks, Varlaam (talk) 05:41, 30 November 2012 (UTC)


 * On "my" wiki, I believe it uses MediaWiki:December and/or MediaWiki:December-gen, but I'm not entirely sure. If you would like to link your an example on your home wiki so I can see what it is returning, I would be happy to take a look and try to help you fix it. -- ShoeMaker   ( Contributions &bull; Message )   22:42, 2 January 2013 (UTC)

Test for existence of Month or Day in Date string?
Is there some way to test if a day or month was part of a date string?

For example, only contains a year, but returns a string formatted with the current month and day. I'd like to be able to return empty if passed on month or day (e.g. like, but returning empty if there is no month part of the date). Curly Turkey (talk) 23:57, 31 December 2012 (UTC)

  returns   returns I'm assuming you are hoping to use this as part of a template that will have values passed in to it, is that correct? If so, what is your list of arguments, what do you hope the template can do, and do you have a link to the template creation sandbox or wherever that you have started to make this so I can take a peek and hopefully understand what you want. -- ShoeMaker  ( Contributions &bull; Message )   22:52, 2 January 2013 (UTC)
 * I want to help you, but I'm not entirely sure what you are asking for.

See also Scribunto ?
Now, we have modules in scribunto/Lua and the syntax to call them is " {{#invoke| ". Then users will try to search them here and we could add Extension:Scribunto to "See also" paragraph ? --Rical (talk) 18:13, 11 May 2013 (UTC)
 * I think you should create a section Extension:Scribunto/Lua reference manual on the extension page, since that should bring this section to the top of the search results when people search "invoke". --Theaitetos (talk) 22:11, 12 May 2013 (UTC)

How can we do a sum ?
Hello ! Is there a function to do the sum of A+B+C+D+E ? Historymating (talk) 11:42, 8 June 2013 (UTC)


 * expr can calculate sums. But it's not possible for any function to process things, that are not in the input area of the function itself. --Theaitetos (talk) 13:58, 28 June 2013 (UTC)

Unwanted whitespace in article from #switch
I'm using a template whose entirety is just a switch statement to transclude one of two possible subtemplates. However, ParserFunctions seems to be adding an extra line of whitespace before the result of the switch statement when I use it this way. Is there a way to remove this whitespace?--Idran (talk) 01:46, 28 June 2013 (UTC)


 * Hello Idran. You should first check if the template adds the white space (line break). If you want to be strict on what gets transcluded via the template make sure you put everything that needs to be transcluded between  tags. Below an example.

Any Template documentation

 * Bla bla 1
 * Bla bla 2
 * Bla bla 3


 * If you don't do that you could easily transclude a line break to a page. --Jongfeli (talk) 08:34, 28 June 2013 (UTC)


 * I disagree with Jongfeli. en:Help:Transclusion has an informative section on how transclusion and the various include tags work.  Idran if you could post the markup from your template here, I would be happy to help you make it work as you expect.  I'm thinking the #switch might not be needed if there are only two outcomes and maybe an #ifeq would work better. Technical 13 (talk) 12:13, 28 June 2013 (UTC)


 * Actually while I was copying the code of the templates here, I noticed exactly what the problem was; I had an includeonly section in the subtemplates that I hadn't realized was adding an unwanted linebreak, and I didn't notice it because I was focusing my attention on the template itself. Apologies for the unnecessary responses!--66.254.228.224 19:26, 28 June 2013 (UTC)


 * Whoops, didn't notice I wasn't logged in; that was me above.--Idran (talk) 19:59, 28 June 2013 (UTC)

Hebrew calendar (Jewish calendar) date as date/time object
Is there a way to enter a Hebrew calendar date as a date/time object in the #time: function? In other words, I know how to get a Hebrew calendar date out by entering a Gregorian date/time object in the function. Can I do it the other way around? Thanks. StevenJ81 (talk) 01:34, 24 July 2013 (UTC)

HTML and Parser functions
I have tried to use Parser functions with HTML(More accurately CSS), but there is some conflict made by the ">" operator. What can I do in order to solve the problem? Thanks. 219.78.217.178 22:40, 9 August 2013 (UTC)
 * Without you showing us the code in question that you are getting errors for, the first suggestion I may offer is to use &amp;lt; and &amp;gt; to achieve &lt; and &gt; respectively. Technical 13 (talk) 23:37, 9 August 2013 (UTC)


 * For example, using a style tag...
 *  180 | 180 | }}$}}deg);'>

The > makes the tag closed and caused errors, so what should I do? 219.78.217.178 10:00, 14 August 2013 (UTC)


 * First, there is a significant typo when closing the parameter degree with  instead of  :
 * If that doesn't fix the problem, try turning the ifexpr around: . --Theaitetos (talk) 18:29, 19 August 2013 (UTC)

Bug in time code?
"Feb" is getting reported as 3 for format letter "n" (see below) Esjs (talk) 16:03, 30 August 2013 (UTC)
 * Sorry for posting here. I've also posted this at Extension talk:ParserFunctions Esjs (talk) 16:18, 30 August 2013 (UTC)
 * Technical 13 (talk) fixed table width by splitting in half at 18:13, 30 August 2013 (UTC)

using #ifexist to check for files in templates
I'm using something like the above in a template to check for files. It works fine, but if files corresponding to $(${PAGENAME}}.png are added after the pages transcluding this template is edited, the files show up in Unused Files list and the File:{{PAGENAME}}.png links show up in Wanted Pages list, not Wanted Files list. Purging any of the relevant pages doesn't fix it. Only editing the pages which have the template transluded updates the link lists. the Is there a way around this bug? - 91.156.198.247 04:56, 8 October 2013 (UTC)

Cleanup number with thousands separator
When calculating with a number like, a number with thousands separator (comma in enwiki) is returned like. Is there a cleanup function, and shouldn't we add that to this helppage? -DePiep (talk) 11:46, 7 November 2013 (UTC)
 * You were looking for Help:Magic words. Some magic words yielding whole numbers have a parameter R, e.g.,  Technical 13 (talk) 10:24, 7 February 2014 (UTC)


 * Thanks! I didn't even know that was there. I've always come here.  But what they have isn't enough for me to follow: If param A begins with / contains (, I want to do X, otherwise Y.  What I have is (for param 2):
 * but it has no effect. Kwamikagami (talk) 11:22, 7 February 2014 (UTC)
 * Happy editing! Technical 13 (talk) 11:55, 7 February 2014 (UTC)
 * I don't understand: It's false whether there's a parenthesis or not.  But someone else found a way of doing this with just {{#if:{{#ifexpr:0{{{2}}}}}|, so I won't need this after all.  (I was trying to do it on my own so someone else wouldn't have to.) Thanks, though.  Kwamikagami (talk) 18:47, 7 February 2014 (UTC)
 * Happy editing! Technical 13 (talk) 11:55, 7 February 2014 (UTC)
 * I don't understand: It's false whether there's a parenthesis or not.  But someone else found a way of doing this with just {{#if:{{#ifexpr:0{{{2}}}}}|, so I won't need this after all.  (I was trying to do it on my own so someone else wouldn't have to.) Thanks, though.  Kwamikagami (talk) 18:47, 7 February 2014 (UTC)
 * Happy editing! Technical 13 (talk) 11:55, 7 February 2014 (UTC)
 * I don't understand: It's false whether there's a parenthesis or not.  But someone else found a way of doing this with just {{#if:{{#ifexpr:0{{{2}}}}}|, so I won't need this after all.  (I was trying to do it on my own so someone else wouldn't have to.) Thanks, though.  Kwamikagami (talk) 18:47, 7 February 2014 (UTC)
 * I don't understand: It's false whether there's a parenthesis or not.  But someone else found a way of doing this with just {{#if:{{#ifexpr:0{{{2}}}}}|, so I won't need this after all.  (I was trying to do it on my own so someone else wouldn't have to.) Thanks, though.  Kwamikagami (talk) 18:47, 7 February 2014 (UTC)


 * Yeah, it wasn't earlier. Using the English Wikipedia version of the module, it works, however, using that version broke multiple templates on this wiki that will need to be updated before I can update the module.  You'll have to take my word for it that it will work properly on the English Wikipedia. :/ Technical 13 (talk) 21:48, 7 February 2014 (UTC)

tags
how can i add tags to my template so if i have only 1 tag it will not display empty spaces or tag icons without words? (sometimes i have a few tags)

Unwanted line breaks in if statements
Hi.

I have the following in a table:

At the end of each #if block I get a    in the HTML leading to ugly line breaks if one or more if the fields is hidden.

Any ideas?

Thanks.

How to insert Vertical Bar (|) in if statement
For example, if I want to insert || if exists, I should use. However, the program will think the Vertical Bars are part of the statement. --Kuwaity26 (talk) 18:35, 18 June 2014 (UTC)


 * See Help:Template#A parameter value containing a pipe character. --Theaitetos (talk) 18:48, 18 June 2014 (UTC)

Maybe an error in documentation
I don't know if I misunderstood what is written, but I really don't understand what means the sentence: "For preventing trimming then- and else-parts, see m:Template:If. Some people use also &lt;nowiki&gt; &lt;/nowiki&gt; instead of spaces.". AFAIK, the &lt;nowiki&gt; can not be used to prevent the trimming of spaces. Can someone clarify this part for me? --Diego Queiroz (talk) 17:36, 4 October 2014 (UTC)
 * Actually it does work:
 * results in
 * Without the nowiki-Tags, you would get:
 * The nowiki-Tags prevent that the whitespace at the beginning and end of the 3rd (then) and 4th (else) parameter gets trimmed. Or you can build a template like the one over at Metawiki: m:template:if. --Theaitetos (talk) 18:40, 4 October 2014 (UTC)
 * Thanks for the answer. Now I got it, but in the current text, it is not clear that it only works for a single space.  My interpretation was that it allows me to use multiple spaces, which is not true.  In addition, it would be good to suggest the use of &amp;nbsp; (or even &amp;#32; for a breakable space), like these:
 * → I thinkDescartes. (non-breakable, allow multiple spaces)
 * → I thinkDescartes. (breakable, does not allow multiple spaces)
 * What do you think? --Diego Queiroz (talk) 21:01, 4 October 2014 (UTC)
 * You're welcome.
 * Well, it does support multiple spaces that way, but websites in general do not display several spaces unless you specify that by CSS or something. But you are right to change the text to clarify the meaning. --Theaitetos (talk) 22:40, 4 October 2014 (UTC)
 * ✅ --Diego Queiroz (talk) 23:57, 18 November 2014 (UTC)
 * You're welcome.
 * Well, it does support multiple spaces that way, but websites in general do not display several spaces unless you specify that by CSS or something. But you are right to change the text to clarify the meaning. --Theaitetos (talk) 22:40, 4 October 2014 (UTC)
 * ✅ --Diego Queiroz (talk) 23:57, 18 November 2014 (UTC)

#ifex
I've disabled the new #ifex section with an includeonly-hack (to bypass the translation XML-comments), because all examples supposed to show how it works fail, and the given reference on Meta (in essence as it was in 2007 created by Patrick) doesn't mention #ifex. If that's for real, where and when was it introduced (and please remove my hack if it's real.) –Be..anyone (talk) 14:51, 17 November 2014 (UTC)


 * No new insights, I'll remove my hack + the hidden #ifex content. –Be..anyone (talk) 23:53, 30 November 2014 (UTC)

Incorrect information on zero padding in #time
Currently the doc lists that if you zero pad a year, it will still be interpreted as one of the 0-99 special years, although both in my usage on another wiki and in the doc it can be clearly seen that is false now (it now acts as the years 0-99). Since this is true, should the doc get updated? --KnightMiner (talk) 23:07, 18 January 2015 (UTC)
 * You are right. Done. --Diego Queiroz (talk) 23:33, 18 January 2015 (UTC)

L'Aquila
The text implies that:

Should return not equal due to ' becoming an escape character.

However if we try it:



Gives:



And even:

Gives:

Exception:

I think the example is bad, though there are a few problem cases. Adam Cuerden (talk) 17:14, 20 January 2015 (UTC)
 * I think the warning is obsolete. And about your last example, it is a special case related with a limitation of the software: "bah_boo" evaluates to "bah boo" (without space).  Note that it is not possible to create a page with "_" in the title. --Diego Queiroz (talk) 03:50, 22 January 2015 (UTC)


 * Actually, on most wikis you have two problems with this attempt at an evaluation. First,  evaluates to   with an upper case B and second there is no "_". To workaround this, you need to use get the lowercase version of the pagename (   &rArr;   ), then you need to combine that with getting the Encoded version of FULLPAGENAME...   &rArr;  .  This gives:
 * &rArr;
 * Happy coding! —  20:18, 22 January 2015 (UTC)
 * Good recipe, maybe only lcfirst limited to the technical issue. –Be..anyone (talk) 17:46, 23 January 2015 (UTC)
 * That's an option depending on exactly what's trying to be accomplished. Alternatively, you could make the string you are comparing against have the upper case first letter since you are expecting a page title and skip case modification all together. —  22:00, 23 January 2015 (UTC)

#titleparts
I've added a note that it strips underscores for spaces, as this actually is rather important behaviour if you want to use it in, say, an #ifeq - we don't want people putting in both cases for comparison because of an undocumented feature.þ

CSS selectors vs #ifexist
The documentation contains the following note of interest:
 * For some use cases it is possible to emulate the ifexist effect with css, by using the selectors  (to select links to unexisting pages) or   (to select links to existing pages).

Since #ifexist can be quite expensive indeed, I'd love to learn more about this. What are those use cases and how are those selectors used? Best, Cavila (MW 1.22, MySQL 5.5.37-0, Php 5.4.4-14 squeeze, SMW 1.9.2, SF 2.7) 07:57, 6 February 2015 (UTC)


 * In any case where you can use styling to achieve the effect you would have used #ifexist for. A missing page icon, for instance.
 * Also note that this is no more or less "expensive" than #ifexist (which is hardly expensive in the first place), it just simply doesn't increment the expensive parser functions count. --137.147.38.65 10:49, 6 February 2015 (UTC)

How to test for numeric strings?

 * 1) iferror doesn't test for numeric strings. How can that be done? --Subfader (talk) 18:56, 12 February 2015 (UTC)


 * Try combining it with, as in  . There is one downside though, which is numerical operators are accepted with your numbers, for example, "1 + 1" is a number rather than a string. --KnightMiner (t/c) 19:55, 12 February 2015 (UTC)


 * I usually is #iferror: with #ifexpr: to determine if something is a number:
 * &rarr;
 * &rarr;
 * &rarr;
 * Good luck and happy editing! —  15:08, 13 February 2015 (UTC)

Ifexist for images
Why does say "doesn't exist", when it definitely does? Liam987 (talk) 20:55, 20 April 2015 (UTC)
 * It is likely because the file is in the commons not here, and so "has been uploaded to the repository, but not to the wiki itself". Compare with, which gives a different answer.  --Clump (talk) 21:49, 20 April 2015 (UTC)

Remainder
Is it possible to use the #expr function to obtain a remainder from a division operation? For instance, returns  (I rounded here), but the remainder is 2 (when handing eight pieces of candy to three kids, two get three each and one only gets two). I want to pull the 2. CycloneGU (talk) 18:38, 2 May 2015 (UTC)

UPDATE: I figured out another way to do it by using something like (that's  by the way), but I would still like to know if it can just be pulled directly so complex formulas don't have to be performed. I did it by using a floor, then remultiplying by the division number and doing simple subtraction. A remainder function would avoid this; I mean, seems so much easier and can be programmed like my example if not already present. It can then be documented. CycloneGU (talk) 20:29, 2 May 2015 (UTC)

Template user config files
It's funny why this statement has not been removed:

"# switch allows an editor [to add information in one template and this information will be visible in several other templates which all have different formatting.]"

A switch can act as a template's configuration file ("to add info in one template... visible in several other templates"). The format of such a config file is a single switch statement in a subpage, called from the template. Because white space is ignored around the | and =, the subpage makes for easy grouping of configuration elements. Even if each line is displayed with a pipe, it is intuitive enough for editors to view or editing the set of template elements. With partial transclusion tags, the display of such a config file can render the switch statement in sections of case/result groupings, each with there own exposition and procedures.

Certainly the part about "all have different formatting" is unclear, because formatting is already provided by wikitext. "Processing" might be more accurate, but still too vague. How about "A #switch function with partial transclusion tags can effect a config file that enables any editor unfamiliar with template coding to view and edit template configuration elements. Examples include w:Template:NBA color, where any user can change the colors of a sports team, and w:Template:Val, where any user can add there own markup and link to the numeric units they want in their article."

Cpiral (talk) 20:01, 13 May 2015 (UTC)