Help talk:Extension:ParserFunctions/2014-2020

Active discussions

#time: and Daylight SavingsEdit

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 Message )   18:30, 9 November 2012 (UTC)

As I see, if it wasn't, now it exist, but doesn't work anyway (#time: I). Ядерный Трамвай (talk) 14:43, 9 September 2016 (UTC)

Square root and other questionsEdit

I had 2 questions about the {{#expr:}} and the {{#ifexpr:}} parser functions:

  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? 14:38, 26 November 2012 (UTC)

Oh, i see that != make negative solutions possitive, but i still need the square root thing. 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 -- 15:08, 26 November 2012 (UTC)
tHANK YOU 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: √X = X^(1/2). Or, in general, X^(1/Y) for the Y-th root of X. --Theaitetos (talk) 22:06, 27 February 2015 (UTC)

#time and full month namesEdit

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 Message )   22:42, 2 January 2013 (UTC)

Test for existence of Month or Day in Date string?Edit

Is there some way to test if a day or month was part of a date string?

For example, {{#time r|2003}} 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 {{#time n|2003}}, but returning empty if there is no month part of the date). Curly Turkey (talk) 23:57, 31 December 2012 (UTC)

I want to help you, but I'm not entirely sure what you are asking for.
{{#time:r|2003}} returns Wed, 06 Aug 2003 00:00:00 +0000
{{#time:n|2003}} returns 8
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 Message )   22:52, 2 January 2013 (UTC)

See also Scribunto ?Edit

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#invoke 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 ?Edit

Cat Fruit
Total sum

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

  1. 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)
Except with lua or java extensions, or similar. Rich Farmbrough 18:51, 5 March 2020 (UTC).
Not even with that, at least not with Extension:Scribunto. A Scribunto module call only sees the module call (and parent template call) parameters, nothing around itself. —Tacsipacsi (talk) 00:48, 6 March 2020 (UTC)
Yeah, you'd have to pass all of the table data in to a Lua module, which could then create the table HTML and also calculate the totals. —Sam Wilson 05:03, 6 March 2020 (UTC)
Yes, that’d be a solution, although quite complicated and far from being intuitive… But at least it works. (Actually you could pass the whole table in one parameter and find the numbers using Lua pattern functions, but that’s no more convenient because of the need to escape all pipes, and even more error-prone as MediaWiki is quite relaxed about table format, which is hard to replicate in Lua.) —Tacsipacsi (talk) 16:36, 6 March 2020 (UTC)

Unwanted whitespace in article from #switchEdit

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 <includeonly> tags. Below an example.
== Any Template documentation ==
* Bla bla 1
* Bla bla 2
* Bla bla 3</noinclude><includeonly>{{#switch:baz|foo=Foo|baz=Baz|Bar}}</includeonly>
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#Markup 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!--Idran (talk) 19:59, 28 June 2013 (UTC)

Hebrew calendar (Jewish calendar) date as date/time objectEdit

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 functionsEdit

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. 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 &lt; and &gt; to achieve < and > respectively. Technical 13 (talk) 23:37, 9 August 2013 (UTC)
For example, using a style tag...
<div style='/*abunchofrandomstuff*/;transform:rotate({{#expr: 360 - 180 + {{#ifexpr: {{{degree|180})} > 180 | 180 | {{{degree|180}}}}}}}deg);'></div>

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

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

Bug in time code?Edit

"Feb" is getting reported as 3 for format letter "n" (see below) Esjs (talk) 16:03, 30 August 2013 (UTC)

{{#time:n|Jan}} {{#time:n|Feb}} {{#time:n|Mar}} {{#time:n|Apr}} {{#time:n|May}} {{#time:n|Jun}}
1 2 3 4 5 6
{{#time:n|Jul}} {{#time:n|Aug}} {{#time:n|Sep}} {{#time:n|Oct}} {{#time:n|Nov}} {{#time:n|Dec}}
7 8 9 10 11 12

using #ifexist to check for files in templatesEdit


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? - 04:56, 8 October 2013 (UTC)

Cleanup number with thousands separatorEdit

When calculating with a number like {{PAGESIZE}}, a number with thousands separator (comma in enwiki) is returned like 28,123. 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#Technical_metadata_of_another_page. Some magic words yielding whole numbers have a parameter R, e.g., {{PAGESIZE:Project:About}} gives 8,736, and {{PAGESIZE:Project:About|R}} gives 8736. –Be..anyone (talk) 00:56, 13 December 2014 (UTC)

Undocumented feature of #timeEdit

Hello, I was just trying something that I thought might work, and it did, despite it not being listed here. it might be useful to add such a note to the page. (if it is noted, then my apologies, but it wasn't obvious)

{{#time: U | second Sunday of March 10:00 }}

Which displays the second sunday in march at 10:00. - 09:34, 16 November 2013 (UTC)

This is documented. Go to Help:Extension:ParserFunctions#.23time and scroll down until you see "Minutes and seconds" in the table to the right. Allen4names (talk) 15:17, 5 February 2014 (UTC)


How can I test if a parameter starts with a parenthesis? I wish to add parentheses to a number template when the uncertainty is input as ±x, but not when it's formatted as (x). So I'd like to test if the first character of the string is a parenthesis, or if the string contains a parenthesis, and only add parentheses when this is false. Kwamikagami (talk) 07:43, 7 February 2014 (UTC)

Thanks. I'm working on WP, which has them installed, doesn't it? Kwamikagami (talk) 08:20, 7 February 2014 (UTC)
  • The English Wikipedia has Extension:Scribunto installed. There is also already a string functions module written which you can see on en:Module:String. What you'll want to use to see if "(" is the first character is {{#invoke:String|sub|{{{1|whatever you are passing in to test}}}|1|1}} 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):
{{#ifeq: {{#invoke:String|sub|{{{2|}}}|1|1}}|"("|| [thing to do if no "("] }}
but it has no effect. Kwamikagami (talk) 11:22, 7 February 2014 (UTC)
  • {{#ifeq: {{#invoke:String|sub|(x)|1|1}}|(|There is a "("| There is no "(" }}
There is no "("
  • {{#ifeq: {{#invoke:String|sub|±x|1|1}}|(|There is a "("| There is no "(" }}
There is no "("
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)


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) — Preceding unsigned comment added by (talkcontribs) 13 March 2014(2014-03-13) 22:07:46 (UTC)

Unwanted line breaks in if statementsEdit


I have the following in a table:

! Website Address
| [[Webpage::{{{Website|}}}]]}}}}
{{#if:{{{Facebook ID|}}}|{{#!:
! Facebook
| [[Facebook ID::{{{Facebook ID|}}}]]}}}}
{{#if:{{{Twitter ID|}}}|{{#!:
! Twitter hashtag
| [[Twitter ID::{{{Twitter ID|}}}]]}}}}

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. — Preceding unsigned comment added by Mitchelln (talkcontribs) 14 March 2014(2014-03-14) 11:38:57 (UTC)

How to insert Vertical Bar (|) in if statementEdit

For example, if I want to insert {{{4}}}||{{{5}}} if {{{4}}} 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 documentationEdit

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 <nowiki> </nowiki> instead of spaces.". AFAIK, the <nowiki> 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:
I think{{#if: therefore |<nowiki></nowiki> I am <nowiki></nowiki>}}Descartes.
results in
I think I am Descartes.
Without the nowiki-Tags, you would get:
I thinkI amDescartes.
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 &nbsp; (or even &#32; for a breakable space), like these:
  • I think{{#if: therefore | &nbsp;&nbsp;&nbsp;I am&nbsp;&nbsp;&nbsp; }}Descartes.I think   I am   Descartes. (non-breakable, allow multiple spaces)
  • I think{{#if: therefore | &#32;&#32;&#32;I am&#32;&#32;&#32; }}Descartes.I think I am Descartes. (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)
  Done [1] --Diego Queiroz (talk) 23:57, 18 November 2014 (UTC)


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 #timeEdit

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)


The text implies that:

{{#ifeq: {{FULLPAGENAME: L'Aquila}} | L'Aquila | equal | not equal}}

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

However if we try it:


{{#ifeq: {{FULLPAGENAME: Æthelred}} | Æthelred | equal | not equal}}



And even:

{{#ifeq: {{FULLPAGENAME: 日本語}} | 日本語 | equal | not equal}}




{{#ifeq: {{FULLPAGENAME: bah_boo}} | bah_boo | equal | not equal}}

not equal

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, {{FULLPAGENAME: bah_boo}} evaluates to Bah boo with an upper case B and second there is no "_". To workaround this, you need to use get the lowercase version of the pagename ( {{lc:{{FULLPAGENAME: bah_boo}}}}bah boo ), then you need to combine that with getting the Encoded version of FULLPAGENAME... {{lc:{{FULLPAGENAMEE: bah_boo}}}}bah_boo. This gives:
{{#ifeq: {{lc:{{FULLPAGENAMEE: bah_boo}}}} | bah_boo | equal | not equal}} ⇒ equal
Happy coding! — {{U|Technical 13}} (etc) 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. — {{U|Technical 13}} (etc) 22:00, 23 January 2015 (UTC)


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.þ — Preceding unsigned comment added by Adam Cuerden (talkcontribs) 20 January 2015(2015-01-20) 17:20:02‎ (UTC)

CSS selectors vs #ifexistEdit

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 a:not(.new) (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. -- 10:49, 6 February 2015 (UTC)
This is what I wanted to clarify: I have a page with a long list of over 100 items. In one column for each item, I want to have a link to a particular page related that item (an example might be a column that links to the "talk" page for that article.) Rather than a space-taking text link that repeats the article name or says "talk" 100 times, I want to use an icon - but I want to use one icon if the page exists and a different icon if the page doesn't (or else no icon). I found #ifexist and figured it is the logical tool to use, only to get a the warning of over-use because there are more than 100 of them. My question was, if I had just used text links, would the wiki not run the same check to decide whether the link is red or blue? Or is #ifexist somehow doing something more complicated or in a more complicated computational way than the typical link check? If it is doing the same thing, I would think CSS would not be any more taxing on the system than #ifexist. 15:04, 17 May 2018 (UTC)

How to test for numeric strings?Edit

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

Try combining it with {{#expr:}}, as in {{#iferror: {{#expr: input text }} | result if not a number | result if a number }}. 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:
    • {{#iferror:{{#ifexpr:{{{someArgument| A text string }}}^0 = 1 | number | string }}| string }} → string
    • {{#iferror:{{#ifexpr:{{{someArgument| 1 + 1 }}}^0 = 1 | number | string }}| string }} → string
    • {{#iferror:{{#ifexpr:{{{someArgument| 5 }}}^0 = 1 | number | string }}| string }} → number
Good luck and happy editing! — {{U|Technical 13}} (etc) 15:08, 13 February 2015 (UTC)

Ifexist for imagesEdit

Why does {{#ifexist:File:Example.png|"exists"|"doesn't exist"}} 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 {{#ifexist:Media:Example.png|"exists"|"doesn't exist"}}, which gives a different answer. --Clump (talk) 21:49, 20 April 2015 (UTC)


Is it possible to use the #expr function to obtain a remainder from a division operation? For instance, {{#expr: 8/3}} returns 2.667 (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 {{#expr: 8 - floor(8/3)*3}} (that's 2 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, {{#expr 8/3 remainder}} 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)

There's a good help page on Meta, most of it created by Patrick from 2006 until 2011: m:Help:Calculation. –Be..anyone (talk) 13:45, 15 May 2015 (UTC)

Template user config filesEdit

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.][clarification needed][examples needed]

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)

No enwiki examples, please. The help pages here are supposed to work on any Mediawiki installation (= also outside of Wikimedia projects). They are also public domain for this job, that's why they were stolenimported from Meta eight years ago. –Be..anyone (talk) 13:52, 15 May 2015 (UTC)

#ifexist to test if user has created own pageEdit


I have tried to use #ifexist to test if the current user has created his/her user page, but {{#ifexist:Special:Mypage always returns true.

Code Result Link
{{#ifexist:User:Rbirmann|1|0}} 1 User:Rbirmann (red link, since I do not have auser page here)
{{#ifexist:Special:Mypage|1|0}} 1 Special:Mypage (always blue)
{{#ifexist:User:Tacsipacsi|1|0}} 0 User:Tacsipacsi (blue, but false since I don’t have a local user page, just on Meta)

Any ideas on how to test if the user has created his page?


--Rbirmann (talk) 18:38, 7 December 2015 (UTC)

I added another case: links to my user page are blue, however, the #ifexist returns false, because my user page comes from Meta. --Tacsipacsi (talk) 20:01, 7 December 2015 (UTC)

#titleparts replacing underscores with spacesEdit

Can this behaviour be reversed/stopped? -- 18:32, 23 December 2015 (UTC)

Checking the existance of a section (I'm trying with #ifexist)Edit

I need to get the information if a section with a regular name exists in a given page.

I've been trying to do that with {{#ifexist: {{FULLPAGENAME}}<-- something --> | true | false }}, where <-- something --> was changed to a lot of things like #Section Name, #Section_Name. I've seen the function does not work with interwiki links but I couldn't figure out how to solve this problem.

The idea is to check if the page has evolved every time a new section is created (wich correspond to a new level). Each section should be named "Level 1", "Level 2" and so on.

I thought about using variables to do that too, but it seems it needs more effort to get thing running right.

If I can get this information, all the rest of my work can continue quite easily.

I hope I'm not asking too much. Thanks.

Andreluciani (talk) 19:36, 26 January 2016 (UTC)

ISO 8601 ordinal day of year (YYYY-DDD) with #timeEdit

The z date formatting code gives the ordinal day of the year starting at zero for 1 January. ISO 8601 starts counting at 1 and always zero-pads its fields. This makes it awkwardly complex to get a properly formatted date: {{#time:Y-}}{{padleft:{{#expr:1+{{#time:z}}}}|3}} instead of just something simple like {{#time:Y-Z}} (and that’s without a custom date which would have to be repeated). So should we add another code? — Christoph Päper 07:47, 11 May 2016 (UTC)

#switch: on a Template {{{parameter}}}?Edit

I am unable to get #switch: to work on a named Template parameter. What is the syntax?

| case Convention
| case Publication=
I want this included for Convention or Publication
| This is the default...

Allenhuffman (talk) 17:45, 31 August 2016 (UTC)

User error. "Case" is not part of the syntax. Allenhuffman (talk) 18:06, 31 August 2016 (UTC)

#if: both A and BEdit

Is it even possible to use function "if" in such case: If both A and B are full/neither A nor B is empty → [something], if any of two is empty → [something else]? I somehow figured out how to use A or B but that's not my case. Thanks in advance, Arvedui89 (talk) 14:45, 15 October 2016 (UTC)

The only way is
{{#if:A|{{#if:B|<both>|<only A>}}|<not A>}}
If you have the chance to use Lua, it’s much easier and simpler:
if (A and B) then --[[ A and B ]] else --[[ one or two missing ]] end
--Tacsipacsi (talk) 22:38, 15 October 2016 (UTC)
Yep, it works for me. I was thinking through it for hours, what makes it obvious to be that simple. Thanks! Arvedui89 (talk) 18:02, 17 October 2016 (UTC)
@Tacsipacsi: Other version :
{{#if: {{#if:A|B}} | <both> | <A or B empty> }}
With this method you don't need to duplicate the code for <A or B empty>. --Zebulon84 (talk) 00:22, 18 October 2016 (UTC)

#ifeq: or?Edit

Can #ifeq be used to compare whether or not a given parameter is equal to one string or another? Like #ifeq A or B then yes, otherwise no. --ArgonSim (talk) 04:49, 12 December 2016 (UTC)

@ArgonSim switch will probably be a better fit: {{#switch:{{{p}}}|A|B=yes|no}}. Dalba 05:06, 12 December 2016 (UTC)

div=/ (Bug ?)Edit

  • 3 / 2 : 1.5
  • 3 div 2 : 1.5
  • 3 / -2 : -1.5
  • 3 div -2 : -1.5
  • -3 / 2 : -1.5
  • -3 div 2 : -1.5

STyx (talk) 18:28, 11 March 2017 (UTC)

Actually, they are defined to be the same. You can round the result: floor(3 / 2) = 1. --Tacsipacsi (talk) 16:59, 15 March 2017 (UTC)

#property and #statementEdit

Please, document parser functions for Wikidata. They are hard to find, only mentioned in Wikibase/Notes/Inclusion syntax and phab:T152780. Also, they have unexpected results. If a property has a deprecated rank #property returns null. --Vriullop (talk) 10:24, 23 March 2017 (UTC)

Help with ParserFunctionsEdit

Hello. I am trying to use ParserFunctions to make a template on another wiki in which {{{1}}} is a date (for example, Jan 1, Nov 25, etc.). If a month has passed since that date, it responds "false", but if a month has not yet passed, it would say "true".
For example, today is May 2. If {{{1}}} is May 1, it would respond with "true". If {{{1}}} is April 5, it would respond with "true". If {{{1}}} is March 30, it would respond with "false". I have been trying to figure out how to accomplish this, but I still have not succeeded. Can someone please help? 2001:569:706A:8E00:AD3A:468E:E393:723B 23:24, 2 May 2017 (UTC)

See if this works:
{{  #ifexpr:  {{#time:U| {{{1}}} {{#time:Y}} }}  >  {{#time:U| now - 1 month}}  | true |  false }}
Dalba 01:24, 3 May 2017 (UTC)
Nope. It just says "Expression error: Unexpected < operator." 2001:569:706A:8E00:AD3A:468E:E393:723B 01:55, 3 May 2017 (UTC)
I think you are not calling it as a template or maybe you've not passed the first parameter. For testing, just replace {{{1}}} with your date, for example:
{{ #ifexpr: {{#time:U| April 1 {{#time:Y}} }} > {{#time:U| now - 1 month}} | true | false }}
Dalba 02:25, 3 May 2017 (UTC)

Help with #timelEdit

When I write {{#timel: Y-m-d"T"H:i:sP}} in the danish wiki, I will get correct local time (+01 in winter, +02 in summer). But when I write this in the faroese wiki, I will get winter time (+00) also when it should be summer time (+01).
Can anybody help? Benadikt (talk) 08:16, 27 May 2017 (UTC)

Set timezone in preferences --wargo (talk) 08:41, 27 May 2017 (UTC)
No. Timezone setting should not effect the wiki content. This is because fowiki uses UTC timezone (like enwiki), which doesn’t have daylight saving time. You can ask to change it to an appropriate one (such as Europe/London) on Phabricator. Developers might ask for local consensus—changing timezone effects not only #timel parser function, but also the signature timestamps, history pages by default etc. --Tacsipacsi (talk) 09:53, 27 May 2017 (UTC)
Thank you very much, I will try to contact the administrators of fowiki first, and then Phabricator. Benadikt (talk) 10:22, 27 May 2017 (UTC)
Hello, I am administartor and Bureaucrat on the Faroese Wikipedia, we are only two administrators and there are not so many active users. I agree with Benadikt, we should of course use local Faroese time on the Faroese Wikipedia. I would be glad, if you could help us to change it. Kind regards --EileenSanda (talk) 13:34, 7 June 2017 (UTC)
Please gain local consensus – if there are few active users, of course you don’t need many votes. Just please leave a note on the village pump and give a few days for the folks to support (or oppose) it. This way your request will certainly not be declined. When the consensus is clear, I will help you post the request on Phabricator. --Tacsipacsi (talk) 18:47, 7 June 2017 (UTC)

#if test string is result of tag extensionEdit

I'm trying to use #if with the tested string being the result of a tag extension. In this case the test result always is "not empty" even when the extenstion returns an empty string, e.g.

{{#if:<mytag something='abc'/>|not empty|empty}}
{{#if:{{#tag:mytag||something='abc'}}|not empty|empty}}
{{#ifeq:<mytag something='abc'/>||not empty|empty}}

The result is always "not empty" even when <mytag ...> returns an empty string. What's the problem? -- 12:32, 15 June 2017 (UTC)

Checked the result of the tag extension using #len:

{{#len:<mytag something='abc'/>}}

The result is always "5", no matter what. But actually printing the result reveals nothing, e.g.

a<mytag something='abc'/>b{{#len:<mytag something='abc'/>}}

results in


What's going on there? -- 13:13, 15 June 2017 (UTC)

See what an expression is transformed to by the parser?Edit

Is there some way to see what an expression containing magic words is transformed to when the magic words are parsed? I want to see what the resulting HTML code of the Chem template on Wikipedia is when I use it with some specific arguments, so I can use similar HTML code myself (because the template doesn't seem to be able to produce the notation I want to have). However, when I use template substitution and press "Show changes", the resulting code is not pure HTML but contains a lot of magic words, which makes it difficult to see what is going on. I would therefore want to convert the expression I get when I use template substitution to code in which all magic words have already been parsed out. —Kri 15:55, 25 June 2017 (UTC)

@Kri Have you tried Special:ExpandTemplates with "Show raw HTML" option checked? Dalba 16:01, 25 June 2017 (UTC)
How do I use it to show the raw HTML of the chem template, which exists on Wikipedia but not on MediaWiki? In the preview, I see Template:Chem which just indicates that the tool can't find the template. —Kri 16:13, 25 June 2017 (UTC)
@Kri Goto en:Special:ExpandTemplates, write "{{chem|4|2}}" in the input text field, check the "Show raw HTML" option, click on "OK". Dalba 16:19, 25 June 2017 (UTC)
Ah, thank you, that worked! :) —Kri 16:34, 25 June 2017 (UTC)

Use #ifexist without it appearing in whatlinkshere?Edit

This causes some major problems with disambiguation page repair on the English Wikipedia when I've been using the function to check for the existence of pages in a Wikidata template - see [2]. Some way of using this without causing links to appear from whatlinkshere would be really useful. Thanks. Mike Peel (talk) 00:11, 16 September 2017 (UTC)

I don't think there is any way around it. Also see phab:T14019. Dalba 02:42, 16 September 2017 (UTC)
  • @Dalba: Wow, this dates back to 2007?! Thanks for the pointer, I had filed a new bug report this eve but have merged it into that one. Hopefully this can be fixed sometime in the next decade... ;-) Thanks. Mike Peel (talk) 22:50, 28 September 2017 (UTC)

Is there a way to count defined parameters?Edit


Is there a way to count defined parameters? The code below is just a base to add to by people who know more than me. Lady Aleena (talk) 21:01, 5 December 2017 (UTC)

{{#if: {{{foo|}}} {{{bar|}}} {{{baz|}}} {{{qux|}}} > 1 | Do something for more than 1 | Do something else for only 1 }}

You can test if the concatenation of them equals any of them:

{{#switch: {{{foo|}}} {{{bar|}}} {{{baz|}}} {{{qux|}}}
| = Nothing
| {{{foo|}}} | {{{bar|}}} | {{{baz|}}} | {{{qux|}}} = One of these
| #default = More than one

although it will count defined-but-empty parameters as undefined. If you want to treat them as defined, I advise you to use Lua (installed on all WMF wikis). —Tacsipacsi (talk) 21:36, 5 December 2017 (UTC)

Thank you for your fast response! However, is there a way to make the default be for one parameter in use, and for the default behavior to do nothing? Lady Aleena (talk) 22:25, 5 December 2017 (UTC)
The above code does exactly that, except that it returns “Nothing” for no parameter. You just have to remove that word. --Tacsipacsi (talk) 22:46, 5 December 2017 (UTC)
Thank you again, have a nice day! Lady Aleena (talk) 23:00, 5 December 2017 (UTC)

Date mathEdit

Hello again.

I am looking to do some math with dates. What would the expression be to calculate how many days have passed between when a date was entered and today?

Let's say that the date entered is 2017-11-01 (or whatever format is the easiest to do math with), how would I figure out how many days have elapsed between then and now? I would like to put this in a switch too, if possible.

{{#switch: {{#expr: ... }}
| >= 180 = red
| >= 90  = orange
| >= 30  = yellow
| #default = blue

So, can this be done? Lady Aleena (talk) 09:59, 14 December 2017 (UTC)

You can subtract {{#time:U}} values and then divide it by an appropriate number (this works, of course, for weeks and smaller time units, as there’s no appropriate number valid for both January and February; you have to compare days, months etc. one-by-one for that). Switch works only for specific values, though, so you need three comparisons embedded in each other. --Tacsipacsi (talk) 13:04, 14 December 2017 (UTC)

Can #switch handle greater and lesser than comparisons?Edit

Hello. Can #switch handle greater and lesser than comparisons like the following? Do I have to put the expression in each? If so, it would still be as long as what I have now with nested {{#ifexpr:}}. Lady Aleena (talk) 01:11, 2 January 2018 (UTC)

{{#switch: {{#expr: 1-{{{number|}}}}}
| >{{=}} 180 = red
| >{{=}} 60  = orange
| >{{=}} 30  = yellow
| blue

I didn't realize I asked the same question right above this one! Lady Aleena (talk) 01:13, 2 January 2018 (UTC)

Problems with years BCEdit

How can I parse dates BC? I need the 4 digitits of a date. Either with "BC" or as negative number. Is there a solution? Thanks for help! --M art in (talk) 09:53, 18 January 2018 (UTC)

What is your input to the parser function? Matěj Suchánek (talk) 18:58, 18 January 2018 (UTC)

#time 6 digit numbersEdit

Is there a way to ask the time function to interpret a six digit number as the year and month? I'd like to put in dates as "20180205" or "201802" or "2018" but can't find a way to do this. Thanks

NemesisAT (talk) 12:30, 7 February 2018 (UTC)

You can use {{padright:{{{1}}}|8|01}} (it might not be absolutely error-prone, but if only four-digit, six-digit or eight-digit dates occur, it should work). For example: {{#time:r|{{padright:201802|8|01}}}} → Thu, 01 Feb 2018 00:00:00 +0000. —Tacsipacsi (talk) 13:32, 7 February 2018 (UTC)
I think that has done the trick. It's for a template that will produce a number for date sorting in tables as well as outputting a human-readable date. Thankyou very much NemesisAT (talk) 15:45, 7 February 2018 (UTC)

#ask in #exprEdit

Hello I'm using this kind of expression {{#expr: {{#ask: [[SomeProperty::SomeValue]] | format=count }} + 1 }} and everytime the number of results for the #ask exceed 19, an error message is displayed. Is there a setting to configure to increase this limit ? Thanks ! --Paul LEMPERIERE (talk) 16:39, 9 February 2018 (UTC)

Automatically count word occurrencesEdit

Hi, I'm looking for a way to create a parser function that can automatically count the number of occurrences of a certain word, and generate it as a number. Is this possible through parser functions? Is this possible at all? I would very much appreciate the help, that you!

It may be possible. The first sentence on the page, states: "It may be configured to provide additional parser functions for string handling; these string functions are documented elsewhere." The functions listed there include #pos and #sub, which together with recursion may be sufficient for your purpose. Hamilton Abreu (talk) 11:39, 11 March 2018 (UTC)

#time:Y with Y/m yields "Error: Invalid time"Edit


I'm currently parsing dates with the #time function (specifically #time:Y). When parsing dates with the format Y/m/d (e.g. 1539/11/01) I'm getting the correct output. When doing the same with dates which don't include a specified day (e.g. dates in the format Y/m like 1539/11) I'm getting "Error: Invalid time" as a result (using "-" as delimiter (e.g. 1539-11) doesn't yield this error message). My question is whether this is a bug which might be fixed in future versions of MW/ParserFunctions (currently still running 1.27.1 with PostgreSQL 9.4.13 and ParserFunctions 1.6.0) or if using "/" as a delimiter in dates is bad practice and should be avoided. Thank you.

— Preceding unsigned comment added by Maxnoeth (talkcontribs) 12:29, 9 May 2018

@Maxnoeth: It uses PHP's strtotime function, which accepts a bunch of formats, and in this case I think you're seeing a clash between "American month and day" mm "/" dd and "Four digit year and month (GNU)" YY "-" mm and the former is giving the "invalid time" error because 1539 isn't a valid month. Sam Wilson 03:00, 10 May 2018 (UTC)

Why is October the same month as October minus 1 months?Edit

Hello, I hope this is not a support question. Check this out:

{{#time:F Y|{{#time:Y-m-d |31.1.2018}} - 1 months }} · {{#time:F Y|{{#time:Y-m-d |31.3.2018}} - 1 months }} · {{#time:F Y|{{#time:Y-m-d |31.5.2018}} - 1 months }} · {{#time:F Y|{{#time:Y-m-d |31.7.2018}} - 1 months }} · {{#time:F Y|{{#time:Y-m-d |31.8.2018}} - 1 months }} · {{#time:F Y|{{#time:Y-m-d |31.10.2018}} - 1 months }} · {{#time:F Y|{{#time:Y-m-d |31.12.2018}} - 1 months }}

has the result December 2017 · March 2018 · May 2018 · July 2018 · July 2018 · October 2018 · December 2018

Isn't this kind of strange? Pd4u (talk) 08:14, 31 October 2018 (UTC)

  • Strange, but rational. When subtracting a month, php's strtotime changes the month to the previous. That is fine if the day of the month exists in the previous month, but if not then the extra days move the month forward again; e.g., March 31 - 1 month = February 31, which is then adjusted into March. --Clump (talk) 11:44, 31 October 2018 (UTC)


This section writes that code <span style="white-space: pre;">foo{{#if:||<nowiki> bar }}foo</nowiki> ignores multiple spaces and explains why. But it actually shows those multiple spaces: foo bar foo, so the section should be corrected. --Tohaomg (talk) 00:43, 4 November 2018 (UTC)

#ifeq always returns false when comparing the value of a variable to a stringEdit


I'm trying to test for the value of a variable to a string but it always returns false so there is definitely something I'm not understanding correctly.

I've just tried this basic line:

{{#ifeq: {{{status}}}| Passed | yes | {{{status}}} }}

Output => Passed


{{#ifeq:{{{status}}}| Failed | yes | {{{status}}} }}

Output => Passed

And any variations I could think of but it always evaluate to False and thus display the value of the variable status. What am I doing wrong?

Thank you

#expr roundEdit

I have 102/49, which is 2.0816326530612, if I write round 3, it says 2.082, but I want it to say 2.081. How do I do? Nico8A (talk) 18:22, 13 March 2019 (UTC)

@Nico8A: {{#expr: floor ((102/49 round 4) * 1000) / 1000}} → 2.081. Note that support questions like yours should not be posted here.    FDMS  4    19:31, 13 March 2019 (UTC)

Rounding to Significant DigitsEdit

I've noticed that many wikipedia pages use `round` with a manually chosen parameter to round an expression to a given number of significant digits. (Eg. This takes a lot of effort to start and maintain and also results in mistakes (for instance, Canada is currently rounded to 4 people / km^2 there). Is it possible to add a round_sig function, which takes an argument specifying the number of significant digits? --Rxtreme (talk) 17:24, 16 March 2019 (UTC)

I second this. Manually choosing the number of decimal places to which to round is not convenient. Significant figures would be a lot better. As would a function to automatically calculate (or guess, when there are trailing zeroes) the number of significant figures in a given amount (which would help avoid false precision with conversions, without losing true precision); right now, string functions would have to be used to achieve this. --Joshua Issac (talk) 19:42, 10 November 2019 (UTC)
I also second this. I used the parser function for a major expansion of a Wikipedia page listing the top career rebounders in NCAA Division I women's basketball. In that sport, rebounds per game are recorded with one place to the right of the decimal point, and zeroes in that position are ALWAYS displayed. However, the "round" parameter cuts off the zero to the right of the decimal point. — Dale Arnett (talk) 03:14, 22 December 2019 (UTC)
I fourth this. e.g. {{#expr:7001/1000 round 1}} displays "7" when what I want is "7.0". I can't see anyway to force exactly 1 decimal point of precision, as in the "%.1f" format string in C, Python etc. Adpete (talk) 09:58, 26 January 2020 (UTC)

File extension switchEdit

Forgive me if I'm overlooking it, but I can't seem to work out how to form a switch based on the extension of a file name (png, gif, etc.). Is this possible? Any tips or guidance much appreciated! Huwmanbeing (talk) 18:25, 30 April 2019 (UTC)

You probably need a Lua module or Extension:StringFunctions##explode:. Matěj Suchánek (talk) 19:49, 30 April 2019 (UTC)

Substitution of #if does not workEdit

{{#if: {{{test|}}} | right | wrong }}

computes to: wrong

{{subst:#if: {{{test|}}} | right | wrong }}

computes to: right

Is this a bug, or am I doing something wrong?

expr Math.log10 emulation: floor ln10 miscalculation (precision error?)Edit

{{#expr:ln1000/ln10}} equals 3 (3).

You would think that {{#expr:floor(ln1000/ln10)}} should equals the same, but instead it's 2 (2).

What's going on? MarMi wiki (talk) 00:49, 5 July 2019 (UTC)

More tests:

{{#expr:floor({{#expr:ln1000}}/ln10)}} = 2

{{#expr:floor(ln1000/{{#expr:ln10}})}} = 3

{{#expr:{{#expr:ln1000}}/ln10}} = 3

{{#expr:ln1000/ln10}} = 3

{{#expr:ln1000/{{#expr:ln10}}}} = 3.0000000000001 MarMi wiki (talk) 01:13, 5 July 2019 (UTC)

It seems that this behavior is correct - for example in javascript Math.log(1000)/Math.log(10) = 2.9999999999999996, and Math.log10(1000) = 3.

Solution: add round 13 in floor [floor(... round 13)]:

{{#expr:floor(ln1000/ln10 round 13)}} = 3

{{#expr:floor({{#expr:ln1000}}/ln10 round 13)}} = 3

{{#expr:floor(ln1000/{{#expr:ln10}} round 13)}} = 3 MarMi wiki (talk) 17:23, 5 July 2019 (UTC)

Request: Implement minus sign for negative numbers (#expr, etc.)Edit

Greetings and felicitations. In #expr (and I assume other functions) negative numbers are indicated with a leading hyphen. Would it be possible to change this to a proper minus sign (−)? E.g., so that the current population estimate in the Wikipedia article Novgorod Oblast displays it? —DocWatson42 (talk) 02:14, 22 July 2019 (UTC)

Looks like phab:T10327. --Matěj Suchánek (talk) 10:26, 22 July 2019 (UTC)

Delay evaluation of parser functionsEdit

Can I delay evaluation of parser functions until the file that transcludes the file that transcludes my code? I have a file (R) that encodes a row of a wikitable, which is transcluded into page T which is a wikitable, which is in turn is transcluded into doc page D that displays the table. Depending on the {{BASEPAGENAME}} of D, I either want to include the row in the table, or not include it. If the parser code is evaluated in the transclusion into T, it will do the wrong thing. So I want to somehow delay the evaluation of my parser code in R, until I get to D. Is there a way to do this? (The way things are organized, I can't push the parser functions up to T, or it would be easy.) Ping, please. Thanks! Mathglot (talk) 04:18, 9 September 2019 (UTC)

Is there a cheaper version of #ifexist?Edit

When opening a page, my browser, MediaWiki, something seemingly checks all the links on that page, coloring the ones that lead to created pages blue and the ones that lead to uncreated red. Is there a way of using this "cheaper" operation, whatever it is, in place of #ifexist? Brightgalrs (talk) 15:13, 1 November 2019 (UTC)

@Brightgalrs: ...What makes you think it's cheaper?
In point of fact, AIUI #ifexist is so expensive precisely because it adds another link to be checked. But since that link isn't static, the result can't be cached, so it has to be run every time the page is rendered.
For other redlinks, ones that are static, MediaWiki caches the results of the check so it doesn't have to re-do it every page load. And since it keeps track of links in both directions, it knows which parts of the cache to update if a redlinked page ends up being created. But #ifexist pushes that check out past the cache and into the page-render step.
Even the "static redlink" check is quite expensive, though — it's only the cache that prevents every page load from being slowed down by it. Again, AFAIUI. -- FeRDNYC (talk) 23:00, 5 November 2019 (UTC)
Also, don't forget the bigger issue with #ifexist: Because of that tracking-links-in-both-directions cache I mentioned, #ifexist acts just like a static [red]link. Meaning, if an #ifexist check fails, MediaWiki will still add the nonexistent target to Special:WantedPages and keep track of it like any other uncreated page. -- FeRDNYC (talk) 23:04, 5 November 2019 (UTC)
I think I'm following you. So is there a way of accessing those cached results, some thing that could be used inline, a template or keyword or something? On the English Wikipedia I'm looking to have many links displayed one way if they are red and another way if they are blue, and being super accurate isn't that important. Brightgalrs (talk) 23:49, 5 November 2019 (UTC)
On English Wikipedia, you can use Extension:TemplateStyles—red links have class="new", while blue ones don’t. Of course TemplateStyles’ CSS can affect only purely presentation, not the HTML code, but that’s what you give up for cheapness. (You might want to exclude external links from the blue links group with :not(.external).) —Tacsipacsi (talk) 09:18, 6 November 2019 (UTC)

Ifexist limitsEdit

I would need an ifexist limit up to 750 on a single page in sl.wikipedia. The instruction says one can increase the limit in LocalSettings.php but I am not sure how to do it. --Janezdrilc (talk) 02:12, 27 December 2019 (UTC)

@Janezdrilc: LocalSettings.php can be edited only by system administrators (not “regular” on-wiki admins). On Wikimedia wikis, you can ask sysadmins with a procedure set in m:Requesting wiki configuration changes, but they will almost certainly decline this change because of its performance impact. —Tacsipacsi (talk) 17:37, 28 December 2019 (UTC)

Ok, I believe you. I'll just split ifexists on two different pages. Thanks for answer. --Janezdrilc (talk) 00:50, 29 December 2019 (UTC)

iferror fails depending on whitespaces inside html tagEdit

I noticed this very strange behavior with #iferror. I would expect all variations of the code below to have the exact same result.

Description Code Result
21 white spaces
{{#iferror:<span                     ></span>{{error|Not ok!}}|ok}}
22 white spaces
{{#iferror:<span                      ></span>{{error|Not ok!}}|ok}}
Not ok!
22 white spaces, closing tag
{{#iferror:<span></span                      >{{error|Not ok!}}|ok}} 
22 white spaces, inside tag
{{#iferror:<span>                      </span>{{error|Not ok!}}|ok}}
22 characters
{{#iferror:<span style="color:limegreen"></span>{{error|Not ok!}}|ok}}
22 characters + 22 white spaces
{{#iferror:<span                      style="color:limegreen"></span>{{error|Not ok!}}|ok}}
Not ok!
28 white spaces in multiple parts
{{#iferror:<span    style="   color:     limegreen;    background:   yellow    ; "    ></span>{{error|Not ok!}}|ok}}
29 white spaces in multiple parts
{{#iferror:<span    style="   color:     limegreen;     background:   yellow    ; "    ></span>{{error|Not ok!}}|ok}}
Not ok!

Any thoughts???

$wgPFStringLengthLimit or $wgPFStringLenghtLimit ?Edit

Lenght in $wgPFStringLenghtLimit = 1000; OR

Length in $wgPFStringLengthLimit = 1000;

— Preceding unsigned comment added by (talkcontribs)

  • Fixed. It is $wgPFStringLengthLimit. See [3]. --Clump (talk) 16:17, 6 March 2020 (UTC)


{{#functionname:{{{parametername}}}|string1|string2|string3|...}} Is there a function which outputs "string1" if "parametername=string1" and "string2" if "parametername=string2" etc. but if any other input it outputs nothing? For example "parametername=something" it would output nothing. My solution to this is: {{#switch:{{{parametername}}}|string1=string1|string2=string2|string3=string3|...}} however it is not as elegant. Is there a function which I can use, other than #switch?Jonteemil (talk) 00:15, 14 March 2020 (UTC)

@Tacsipacsi: You think you might be able to help me out here? It would be very appreciated!Jonteemil (talk) 17:15, 14 March 2020 (UTC)
@Jonteemil: You can use {{#switch:{{{parametername}}}|string1|string2|string3={{{parametername}}}|...}}, although if you switch on something more complex than a single parameter, this will soon become even more complex than the string1=string1 solution. I have no idea that follows the exact pattern in your proposal (which would work fairly well for more complex {{#switch:values). —Tacsipacsi (talk) 17:30, 14 March 2020 (UTC)
@Tacsipacsi: Okay, thanks :).Jonteemil (talk) 17:41, 14 March 2020 (UTC)

Ifeq always returns false when using a variableEdit

As mentioned previously, I'm experiencing the same issue. I think I'll be able to find a way around it. NemesisAT (talk) 20:37, 1 April 2020 (UTC)

Return to "Extension:ParserFunctions/2014-2020" page.