# Help talk:Extension:ParserFunctions

## #ifexist problem

I'm creating a template to redirect red links to wikipedia, here's the content of the template :

{{#ifexist:{{{1}}}|[[{{{1}}}]]|[[w:en:{{{1}}}|{{{1}}}]]}}


theorically if {{{1}}} exists output [[{{{1}}}]], if doesn't exist output [[w:en:{{{1}}}|{{{1}}}]], function seems right isn't it?

practically, it works with one word, for instance it works with

{{w|Example}}


, w being the name of the template but when it comes with spaced words such as

{{w|Test Page}}


, output is Page Test Page and link is w:en:Test

why is spacing causing issues? I don't get it, if anyone can help me, thanks.

Use {{fullurl:{{{1}}}}} rather than hardcoding the enwiki domain. The actual problem you're experiencing is that the division between the link target and the link text is placed at the first space in the expanded string, so you need to replace spaces with underscores in the first parameter; fullurl will do that for you, and also make the template portable to other wikis. Happymelon 16:20, 28 August 2011 (UTC)
No, it doesn't seem right. External links must not contain spaces. Try using {{urlencode:{{{1}}}|WIKI}} as part of the url.
{{#ifexist:{{{1}}}|[[{{{1}}}]]|[http://en.wikipedia.org/wiki/{{urlencode:{{{1}}}|WIKI}} {{{1}}}]}}


Gustronico 20:08, 28 August 2011 (UTC)

Fullurl didn't make it. So I tried the solution of Gustronico, the title works but the link doesn't, the space is replaced by a plus sign. It gives w:en:Test+Page

Edit : anchorencode works, but it won't work with special characters while urlencode can! If there's any solution it would be great.

You can use interwiki linking. I think it is standard to have them to the English Wikipedia, otherwise see Manual:Guide to setting up interwiki linking. On this site: w:Test page or Wikipedia:Test page. If for some reason you want external link style: {{fullurl:w:Test page}} gives //en.wikipedia.org/wiki/Test_page .--Patrick1 12:06, 3 September 2011 (UTC)

Did you put the |WIKI parameter in urlencode? It would return underscores for spaces:

• {{urlencode:Test Page}} → Test+Page
• {{urlencode:Test Page|WIKI}} → Test_Page
• {{urlencode:Test Page|QUERY}} → Test+Page
• {{urlencode:Test Page|PATH}} → Test%20Page

Gustronico 20:38, 3 September 2011 (UTC)

## Logical OR failing?? (Nope, I just fail.)

Hello. This expression should return "EXPANSION IS TRUE", but returns "EXPANSION IS FALSE":

• BOOLEAN ALGEBRA: {{#ifeq: {{#ifeq: 0 | 1 | 0}} OR {{#ifeq: 1 | 1 | 0}} OR {{#ifeq: 0 | 1 | 0}} | 1 | EXPANSION IS TRUE | EXPANSION IS FALSE }}:
BOOLEAN ALGEBRA: EXPANSION IS FALSE;

Likewise, the below code should return TRUE [(1 || 0 || 0 = 1); should be TRUE] but returns FALSE:

• SIMPLE BOOLEAN ALGEBRA: {{#ifeq: 1 OR 0 OR 0 | 1 | TRUE | FALSE }}:
SIMPLE BOOLEAN ALGEBRA: FALSE

I'm running MediaWiki 1.16.3 with ParserFunctions (Version 1.4.0). Help! 17:39, 4 August 2011 (UTC)

I think you will need to use #ifexpr, as in {{#ifexpr: 1 OR 0 OR 0 | TRUE | FALSE }}, which returns:
TRUE
Analogously, {{#ifexpr: {{#ifeq: 0 | 1 | 1 | 0}} OR {{#ifeq: 1 | 1 | 1 | 0}} OR {{#ifeq: 0 | 1 | 1 | 0}} | TRUE | FALSE }} returns
TRUE
Helder 18:12, 4 August 2011 (UTC)
Erm. You're quite right here. How embarrassing for me; I've been looking at this for too long and completely missed this. Sorry about that, and thanks for the help! 18:34, 4 August 2011 (UTC)

## #time

Why is it that the time function y only works for years before 2000? For example, {{#time: y | 2002 }} yields 08 (currently, when the year changes to 2009 presumably it will yield 09 at that point) when it should yield 02. This is very frustrating when trying to construct things utilizing dates with 2 digits. It doesn't seem to matter for 1999 and before, though. Examples:
{{#time: y | 2020 }} yields 20
{{#time: y | 2002 }} yields 02
{{#time: y | 1998 }} yields 98
{{#time: y | 1965 }} yields 65
Thanks for any help that anyone may be able to provide. I had no idea where to post this question, but hopefully this is the right spot. 24.236.101.233

Also, I edit mainly on wikipedia (sorry for not having a username here). If/when this is fixed, would it automatically update on wikipedia or not? Sorry, I didn't know how that worked. Thanks again for any info anyone might be able to provide. 24.236.101.233 09:52, 30 December 2008 (UTC)
The problem is that if you use {{#time: j F Y H:i | 2003 }}, you get 24 May 2003 00:00, like for {{#time: j F Y H:i | 1923 }} (24 May 1923 00:00). iAlex 12:56, 30 December 2008 (UTC)
You just need to make the date look more like a date. A 4 digit number staring with a 2 isn't enough. Try: {{#time: y | {{#time: F }} 2002 }} or {{#time: y | December 2002 }}. See strtotime. Splarka 21:35, 30 December 2008 (UTC)
It is possible with some minor limitations to use #time for specifying dates from -6999BCE to 6999CE. It requires some template hackery to bypass normal limitations of #time, but it is possible to do. One limitation is that there is no way of recognizing the precision the editor intended for certain dates and times. EG: if seconds were specified as 00, there is no way (that I have come up with yet) to tell if the user simply omitted the seconds because they didn't measure with that precision. For example of the lengths I had to go to in order to get this functionality, see code at {{:en:Template:start-date}}. (Note- you won't be able to see the results of the calculations from preview- the easiest way to see the UTC value emitted is to turn off CSS, eg, Opera View.Style.User mode. Look for the UTZ value in parens following the visible date-time.) -J JMesserly 20:05, 17 February 2009 (UTC)

I am wondering why the format code "z" delivers the day of the year starting with 0, deviating from the ISO-8601 standard, which counts from 1 to 365 (or 366). Someone recently used this code in the en:ISO-8601 article, giving wrong results. Question: was the definition here intentionally deviating? If so, how can the correct ISO ordinal date be displayed; if not please revise the magic word. −Woodstone 07:33, 11 June 2010 (UTC)

## #switch

Quote from help: It is possible to have 'fall through' values, where several case strings return the same result string. This minimises duplication. — It doesn't seem to work for me. Instead, an empty string is returned for cases where right-hand side is emty. --Lozman 14:19, 3 January 2009 (UTC)

I fixed the description.--Patrick 10:20, 4 January 2009 (UTC)
Thanks a lot! Now it works OK. --Lozman 11:11, 4 January 2009 (UTC)

I have used #switch to return one string at {{templ|begin}} and a different one at {{templ|end}}. This works very well, however one of my strings had a leading space. This was not parsed correctly, the space was ignored. I have had to precede it with a line break for it to work. 213.126.244.228 14:36, 17 February 2009 (UTC)

### subsequent cases

I wonder if there is any good reasons why subsequent cases are not supported. They would save some time and Code I think. Think of something like the following:

{{#switch:
|1=1 foo
|2=2 foo
|3=3 foo
|1
|2=1+2 foo
|1
|3=1+3 foo
}}


--Danwe 00:26, 18 June 2009 (UTC)

They are supported. That example will work perfectly, when you specify a test string as the first parameter. It is not particularly useful, however, because an input of 1 will always match the first case encountered (the "1 foo" case). However, a statement like this:
{{#switch: {{{input}}}
| foo = You entered 'foo'
| bar = You entered 'bar'
| baz
| quok = You entered either 'baz' or 'quok'
}}

Will work perfectly. Happymelon 08:08, 18 June 2009 (UTC)
I know that this will work perfectly but this is not what I meant. I meant subsequent cases, match each "1" and not only the first "1". That would be the same behavior than in C++ for example where you can stop it with the break kommand. --Danwe 14:20, 21 June 2009 (UTC)
No, the behaviour in languages like C++ is to scroll through the cases until a match is found, then to execute all the remaining statements in the switch until a break is found. So the output of a statement like your example in C++ would be "1 foo2 foo3 foo1+2 foo1+3 foo" What you want is the output to be "1 foo1+2 foo1+3 foo", right? That's basically just string substitution. How would that be useful? Happymelon 21:24, 26 June 2009 (UTC)
This would be usefull if some cases should have the same output and the output is very long so you don't want to write it down for all the cases. --Danwe 18:48, 5 July 2009 (UTC)
Not sure whether this is exactly the thing you want, but I have a simple patch which I belief does this exact thing (I needed it), but it might nearly definitely break some other functionality: replace line 220 ( "return trim( $frame->expand($valueNode ) );" ) with ($returnvalue .= trim($frame->expand( $valueNode ) );") and add a line between 241 and 242 containing "if($returnvalue != "") return $returnvalue;". Lastly it might be necessary to add "$returnvalue = null;" at the begin of the function. -- David Mulder (can't login) 77.95.97.53 11:17, 6 January 2010 (UTC)

## Example for first black president

Bush

The above example should change on Jan. 20, 2009. --Ed Poor 20:40, 9 January 2009 (UTC)

That won't because there is no Template:Age in days on this wiki, and even if there were, #if only checks nullity. Try something like:
{{#ifexpr: {{#time:U}} > {{#time:U| January 20 2009}}|Obama|Bush}}
Splarka 22:45, 9 January 2009 (UTC)

## Using #if to call an image and adding attributes

I am trying to use #if to call an image. I don't want this image to link to its source page or anywhere. I think that I can do that by using "|link=" as an attribute but I can't get it to work. Anyone able to help?

1. if:|[[Image:{{{Logo}}}|130px|]]
well, this:
• {{#if:1|[[Image:Wiki.png|30px|link=]]}} >
• {{#if:|[[Image:Wiki.png|30px|link=]]}} >
Works for me, but note that the link= parameter is new to version 1.14 which isn't released yet. Splarka 08:25, 15 January 2009 (UTC)

Errrrm - so does that mean that I have to wait for 1.14 and upgrade or is there a workaround? I tried it in mine and it didn't work - you can still click on the image and get through to the Image page, which is what I want to disable :( .

Only if you want to wait for the quarterly release, if you're ambitious you can Download from SVN to get the latest version. --Tlosk 10:46, 30 January 2009 (UTC)

## Move to Help:ParserFunctions

I don't know if anyone else noticed, but Help:Extension: looks ridiculous. I amend that we move this page to the above link. -PatPeter 00:23, 18 January 2009 (UTC)

I think the distinction can be helpful in that Help: applies to a default installation and Help:Extension: makes clear that the information applies to an added extension. --Tlosk 10:38, 30 January 2009 (UTC)

## HTML in #IF statement branches is not rendered as html but as plain text

In this example I want to include or exclude a row of a talbe based on the presence of a passed paramter:

{{#if: {{{room}}} |
<tr>
<td></td>
<td></td>
<th>
Room {{{room}}}
</th>
<td></td>
<td></td>
</tr>
|  }}


However what happened is the html is renderes as plain text and I get a bunch of HTML code showing up on my page.

How can I prevent this?

Thanks, Pete.

## iftrue

Isn't there also a {{#iftrue: function? Mglovesfun 13:50, 2 May 2011 (UTC)

No, although there was a template by that name on the English Wikipedia several years ago. —Emufarmers(T|C) 22:14, 2 May 2011 (UTC)

## Fully (recursively?) substituting within a switch

Hi, I'm trying to write a template that will randomly substitute one of four messages. I've got the random part down by using a mod function with time, but I can't get just the text to substitute. When I call it with a {{subst:randomtemplate}}, it grabs a new time and therefore a new message. It seems like a recursive template as in the docs, and I've tried every combination of <includeonly>subst:</includeonly> I can find anywhere in the template, and I still can't get it to work. I'd even settle for leaving the switch function in place and substituting the mod time value, but I can't even get that to work.

Template so far:

{{#switch: {{<includeonly>subst:</includeonly>{{#expr:{{#time: s}} mod 4}}}}
|0=message 1
|1=message 2
|2=message 3
|3=message 4
}}


Thanks! Staeiou 03:44, 11 July 2011 (UTC)

Figured it out, turns out you have to subst everything and put includeonly tags around the entire template. So behold, a random template generator:
<includeonly>{{subst:#switch: {{subst:#expr:{{subst:#time: s}} mod 4}}
|0=message0
|1=message1
|2=message2
|3=message3
</includeonly>

Staeiou 19:16, 11 July 2011 (UTC)

## Trimming

I wish the parser functions did not trim the leading/trailing spaces and other characters. I am having trouble adding spaces and paragraph marks on these functions. Ganeshk 15:51, 24 September 2011 (UTC)

## Using #if to generate conditional table rows

I'm running into a problem using #if to generate multiple conditional rows in succession. The issue, I believe, stems from line breaks, or lack thereof. If you use line breaks to separate the #if statements, new rows created with |- will appear correctly, but when the condition is false, the line breaks are still generated as white space (html P or BR), causing the last cell to have an extra line. On the other hand, if you keep the #if statements on the same line, there appears to be no way to generate a line break at the start of the output because the parser strips it. So |- will not appear on a new line, and therefore fails to generate a new row (it instead just gets rendered as text). 76.253.0.17 03:12, 26 September 2011 (UTC)

Same probleme here. Found any solution? Drhirn 13:03, 8 November 2011 (UTC)
Why not just just use html tags? --Subfader 18:14, 8 November 2011 (UTC)
Try using the same-line method and placing a invisible character (like &8201; or &#8203;) at the beginning of the output, before the line break. The innocuous character will then be added to the end of previous cell, and the line break will not be ignored. Note:&8201; is a very thin space and &#8203; is a zero-width space. Gustronico 17:47, 17 November 2011 (UTC)

## #switch

How many parameters can I put into a single #switch?--90.217.236.107 09:59, 22 October 2011 (UTC)

## Multiple #if

Is it possible to use the #if function for multiple articles? For example, IF this article AND that article exist, THEN 1; IF this article exists and that NOT, THEN 2; IF this article does NOT exist and that exists, THEN 3; IF both articles do NOT exist, THEN 4. I tried it many times using IF in IF, but it was effectless. Thanks.--Kiril Simeonovski 10:47, 27 December 2011 (UTC)

I would use {{#expr: {{#ifexist: <ARTICLE1> | 1 | 0 }} + {{#ifexist: <ARTICLE2> | 2 | 0 }} }}, which will give you values 3, 2, 1 and 0, respectively, for the four cases you described. Or if the numbers are particularly important, by playing around a bit you should be able to get the exact numbers you want out. Happymelon 12:16, 27 December 2011 (UTC)
Thanks once again. I didn't even imagine it's possible to use "+" sign.--Kiril Simeonovski 13:34, 27 December 2011 (UTC)

## Checking if an external link exists

Is there a way to use #if, #ifeq or other ParserFunctions to check if an external URL exists or not (i.e., whether a web page is a dead link)? Smuconlaw 17:59, 15 January 2012 (UTC)

No. The wiki parser knows the status of its own pages only by checking its internal database (it does not actually try to load the webpage). It has no way of knowing whether pages exist if they are on unrelated domains. On some wikis, experienced editors occasionally run bots to check the status of external links and edit wikitext containing broken links, but that is unrelated to parser functions. — Richardguk 22:50, 15 January 2012 (UTC)
Ah, OK. Thanks. A template ({{Singapore Statute}}) at the English Wikipedia relies on an external website, but the managers of that website have launched an updated website which is quite different. I was wondering if the template could be tweaked to check if the old website is still accessible, and, if not, to access the new website instead. Looks like I should wait till the old website has been completely turned off, then rejig the template to link to the new website. — Cheers, SMUconlaw 09:56, 16 January 2012 (UTC)

## ifeq match this or that

Is there a way to compare multiple values with a string?

{{#ifeq: this | value1 OR value2 OR value3 | yes | no }}


I know I could nest the #ifeq-tags but that results in ugly tag soups.

I could also use #switch but then i have to repeat the output for each. --Subfader (talk) 18:23, 26 March 2012 (UTC)

#switch will accept multiple possibilities for each output, so the following would output "yes" for this equal to any of "value1", "value2" or "value3", or output "no" otherwise:
{{#switch: this | value1 | value2 | value3 = yes | #default = no }}

See Help:Extension:ParserFunctions#Grouping results for a different example.
Richardguk (talk) 18:41, 26 March 2012 (UTC)
Oh, great :) --Subfader (talk) 06:49, 27 March 2012 (UTC)

## No integer division ???

Why is there no integer division for #expr ? There is a modulo operator but no integer division. This is not logical to have one feature and not the other.

We have to subtract 0.5 and then round to 0 digits. Instead div should be the integer division and / should be the decimal division.

--DavidL (talk) 13:32, 15 April 2012 (UTC)

## Template:Ifnumber

To simplify a complex template, I made a Template:Ifnumber witch detect if an expression is numeric, but else do not generate any error.
example : {{Ifnumber| 231 | true text | false text }}
Is it a short equivalent, or this template could become a parse function ? Rical (talk) 15:29, 15 April 2012 (UTC)
I don't think we need to add another ParserFunction for a feature that can be so easily achieved with a short amount of code using existing functions. Happymelon 14:11, 17 April 2012 (UTC)

## Creating a new line...

I am wondering if any of you guys can help me. I am attempting to use ParserFunctions to create a unit converter for my wiki. The issue is that the "#expr" code is creating a new line after every use. My code is below. Any help would be SOOOOO appreciated! Thanks!!! --Zackmann08 (talk) 22:22, 1 May 2012 (UTC)

The template:

<includeonly>"{{#expr:({{{1}}}* 2.2046)round2}} lbs ({{{1}}} kg)"</includeonly>


The use of the template:

* '''Weight''': {{convert/kg|1}}
* '''Weight''': {{convert/kg|2}}


What it produces:

• Weight: "2.2 lbs (1 kg)"

• Weight: "4.41 lbs (2 kg)"

What I WANT it to produce:

• Weight: "2.2 lbs (1 kg)"
• Weight: "4.41 lbs (2 kg)"

Hello, you have to make sure that the transcluded part is inline (when you need it to be). This means no Enters in the part that will be transcluded with the template. This can go wrong when you transclude a category with a template. If there is a Enter after the category it will get transcluded. Also, when you save the page starting with a Enter it will not show when you edit it again but it is still there. If you want more layout control we always exactly "tell" the wiki engine what needs to be transcluded. See example that will work below (on MW 1.17.2):
[[category:test]]<noinclude>
== Any Template documentation ==
* Bla bla 1
* Bla bla 2
* Bla bla 3</noinclude><includeonly>"{{#expr:({{{1}}}* 2.2046)round2}} lbs ({{{1}}} kg)"</includeonly>


When you have a Enter between the category and the <noinclude> it will mess up the result. --Jongfeli (talk) 11:46, 2 May 2012 (UTC)

THANK YOU SOOOOO MUCH!!!!! That really helped!!! --Zackmann08 (talk) 22:20, 2 May 2012 (UTC)

## lenght of a string

Hi, I just want to share parser function to find lenght of a given string.You can find the template here, but it is in Turkish. It is up to 10 characters but you can increase. the size.

• code =

{{ #ifeq: {{padleft:|1|{{{1|}}}}} | {{{1|}}} | 1 | {{ #ifeq: {{padleft:|2|{{{1|}}}}} | {{{1|}}} | 2 | {{ #ifeq: {{padleft:|3|{{{1|}}}}} | {{{1|}}} | 3 | {{ #ifeq: {{padleft:|4|{{{1|}}}}} | {{{1|}}} | 4 | {{ #ifeq: {{padleft:|5|{{{1|}}}}} | {{{1|}}} | 5 | {{ #ifeq: {{padleft:|6|{{{1|}}}}} | {{{1|}}} | 6 | {{ #ifeq: {{padleft:|7|{{{1|}}}}} | {{{1|}}} | 7 | {{ #ifeq: {{padleft:|8|{{{1|}}}}} | {{{1|}}} | 8 | {{ #ifeq: {{padleft:|9|{{{1|}}}}} | {{{1|}}} | 9 | {{ #ifeq: {{padleft:|10|{{{1|}}}}} | {{{1|}}} | 10 | 11}}}}}}}}}}}}}}}}}}}} Saltinbas (talk) 15:15, 14 May 2012 (UTC)

## #switch/#ifeq with apostrophes

For example, if you're matching a pagename that contains an apostrophe to the plain text version

{{#ifeq: {{PAGENAME}}|The Page's Name|y|n}}

the result always comes out to be 'n', oddly.

Anyone know a loop around this? --108.224.95.15 05:50, 25 July 2012 (UTC)

Nevermind, replacing the apostrophe with &#39 ; works. --108.224.95.15 05:54, 25 July 2012 (UTC)

## replacing #ifexist with #dpl

The behaviour of #ifexist can be reproduced with DPL using the following syntax:

{{#dpl:title= page title |oneresultheader= value if exists |noresultsheader= value if doesn't exist }}

which is equivalent to:

{{#ifexist: page title | value if exists | value if doesn't exist }}

DPL has the advantage that it does not create a link between the target page (page title) and the page containing the query. Using #ifexist would cause your page to be listed in Special:WhatLinksHere/page_title.

Capmo (talk) 06:42, 18 August 2012 (UTC)

#ifexist is faster. Avoid calling DPL wherever you can. --Subfader (talk) 13:23, 19 August 2012 (UTC)
DPL makes direct queries to the database, what can be faster than this? And there must be a reason for #ifexist to be labeled as an "expensive parser function". The wiki I administer uses DPL extensively for all sorts of things, and we don't feel any perceivable degradation in server performance. Capmo (talk) 21:53, 21 August 2012 (UTC)
Initializing DPL on page load takes longer than ParserFunctions.
"#ifexist to be labeled as an "expensive parser function"" that's because the DB load gets expensive on calling it X times, but the same counts for calling DPL X times on a page... --Subfader (talk) 11:50, 22 August 2012 (UTC)

## If A or B or C (resolved)

I am trying to use the if statement to test for multiple different values.

For example: {{#if: {{{a|}}}{{{b|}}}{{{c|}}}| YES | NO}} would display "YES" if any of the three (a,b,c) variables were defined. If, and only if, all 3 were NOT defined, it would display "NO".

I simply cannot get this to work! Any help would be most appreciated.

--Zackmann08 (talk) 01:09, 10 September 2012 (UTC)

Try it like this {{#if:{{{a|}}}|YES|{{#if:{{{b|}}}|YES|{{#if:{{{c|}}}|YES|NO}}}}}}. If one of the parameters has a value it will display YES, only when non of the parameters has a value it will display NO. In this way you can make any combination you want and make it as complicated as you want. --Jongfeli (talk) 09:03, 10 September 2012 (UTC)
The issue is that I am attempting to use this to do something much more complex than just displaying "YES" and "NO". I am using it to create a rather large table. Is there no way to do "If A or B or C"? --Zackmann08 (talk) 13:50, 10 September 2012 (UTC)
If I understand you correctly you would like to fill a (calculated) column in a table and the value depends on other values in the same row? I tried this in combination with Extension:External Data but {{#if: does not work because it probably always gets a value back from the Query. It does not matter if there is a database NULL in the table or an empty string. Just to see if it can work I tried {{#ifeq: (see example below) but it only works on the first row it displays, if in the first row a = 1 it will display Yes and it will repeat the result on the rest of the rows even if a is not 1.
  {{#for_external_table:expression}}
{| class = "wikitable"
! Column 1
! Column 2
! Column 3
! Test{{#for_external_table:<nowiki/>
{{!}}-
!{{{a}}}
{{!}}{{{b}}}
{{!}}{{{c}}}
{{!}}{{#ifeq:{{{a}}}|1|Yes|No}}
}}

Maybe I am doing something wrong but it seems that in combination with External Data the ParserFunctions does not handle each row individually. --Jongfeli (talk) 15:19, 10 September 2012 (UTC)
This is part of an infobox. I am trying to copy the technique used on wikipedia (For example: http://en.wikipedia.org/w/index.php?title=Template:Infobox_weapon&action=edit)
In the example below, the heading for the "Service History" only displays if "service", "used_by" or "wars" is defined. For some reason, this exact syntax is not working for me.
<!------------------------------Service history------------------------------>
{{#if:{{{service|}}}{{{used_by|}}}{{{wars|}}} |
! colspan="2" {{WPMILHIST Infobox style|header_bar}} {{!}} Service history
}}
|-
{{#if:{{{service|}}} |
! style="padding-right: 1em;" {{!}} In service
{{!}} {{{service|}}}
}}
|-
{{#if:{{{used_by|}}} |
! style="padding-right: 1em;" {{!}} Used by
{{!}} {{{used_by|}}}
}}
|-
{{#if:{{{wars|}}} |
! style="padding-right: 1em;" {{!}} Wars
{{!}} {{{wars|}}}
}}
|-

--Zackmann08 (talk) 15:47, 10 September 2012 (UTC)
So its now working. Not sure what i was doing wrong... Oh well! --Zackmann08 (talk) 16:26, 10 September 2012 (UTC)

## If number check (resolved)

I am attempting to write an error checking function that checks to see whether a user has supplied either a year (####) or the word "Present". (This is for an infobox for a vehicle. I want to display the production years.) I am 99% of the way there with the following:

{{#iferror:{{#expr: 0 + {{{1}}}}}|{{#ifeq:{{{1}}}|Present|<!--DO NOTHING-->|<!--Display some error message-->}}}}


The issue that I am having is that if a valid date is supplied, then the expression ({{#expr: 0 + {{{1}}}}}) evaluates and is displayed. Is there an easy way to suppress that expression? I seem to remember seeing a "span display=none" type thing somewhere...

Any advice will be greatly appreciated.

--Zackmann08 (talk) 14:35, 19 September 2012 (UTC)

I love solving my own problems. :-) <span Style="display: None"> was my solution. --Zackmann08 (talk) 14:40, 19 September 2012 (UTC)
I also had a similar question because the parser functions give script errors in some cases. I had do this. --Rical (talk) 22:50, 19 September 2012 (UTC)

## How to use tag function within parser function?

I'm trying to build an if-clause that automatically inserts

== References == <references />


into the article if there are some <ref>s entered in the wikitext. If there's no <ref> no heading and no references/ should be inserted.

I tried different things but none of them work - that means I always get "Heading and stuff" even if there's no ref tag entered in the article:

{{#if: <references /> | Heading and stuff | }}
{{#if: {{#tag:references|}} | Heading and stuff | }}


The docu says "Content inside parser tags (such as nowiki) is temporarily replaced by a unique code" and shows that tags won't work.
Is there a workaround to let <references /> be parsed inside the #if?
--Stefahn (talk) 17:38, 9 November 2012 (UTC)

Just for the record: Found a solution/workaround now :) Stefahn (talk) 17:59, 3 April 2013 (UTC)

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

## Square root and other questions

Hello,
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?

80.230.37.167 14:38, 26 November 2012 (UTC)

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)

## #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 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, {{#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 Sat, 24 May 2003 00:00:00 +0000
{{#time:n|2003}} returns 5
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)

## Expression error: Unexpected < operator.

I'm trying to add Extension:DPL Page Name S/N Maker (using SemanticForms) (which is really just a complex template combining multiple other extensions) to a corporate wiki, but for any result higher than "00001" it keeps kicking out the error message Expression error: Unexpected < operator. This error isn't covered on the help page here, but based on the documentation I assumed that it must be a stray < character or possibly a tag inside a function where tags aren't allowed. However, even when I remove all instances of the < character from the template (by eliminating the comments, the <strong> tags, and the <noinclude> tags), the error message persists.

Here is the text of the template:

[removed]

Any idea what the problem is and/or how I can correct it? Thanks! ~ Michael Chidester (Contact) 15:07, 22 March 2013 (UTC)

### Solution

Ultimately I determined that this was a DPL conflict, possibly due to the {{expr:}} function refusing to parse the standard output format of DPL. To help anyone having this problem in the future, here is my modified code, changing out the deprecated string functions for their replacements and modifying the DPL output to produce a regular string rather than a link:

{{#if: {{{form|}}}
|  {{#ifexist: Form:{{{form|}}}
|
| <strong class="error">Warning! The form "{{{form|}}}" may not be a valid form name!</strong>
}}
|
}}<!---
-->{{#if: {{{form|}}}
| {{#ifeq: {{lc:{{NS:{{{namespace|}}} }} }}
| {{lc:{{{namespace|}}} }}
|
| <strong class="error">Warning! "{{{namespace}}}" may not be a valid namespace name!</strong>
}}
|
}}<!---
-->The next document number is '''<!--
-->{{#if: {{{namespace|}}} | {{{namespace|}}}: }}{{{prefix|}}}<!--
-->{{padleft:<!----------- (X+1)                         =>  0000(X+1)
-->{{#expr:<!---------- 0000X+1                       =>  (X+1)
-->{{replace|<!----- "Namespace:prefix0000X"       =>  "0000X"
-->{{replace|<!-- "*[[Namespace:prefix0000X]]"  =>  "Namespace:prefix0000X"
-->{{#dpl:<!-- return pages named "*[[Namespace:prefix0000X]]"
-->titleregexp =^{{{prefix|}}}[0-9]{{{{pad|5}}}}$<!-- -->| namespace = {{{namespace|}}}<!-- -->| order = descending<!-- -->| mode = userformat<!-- -->| format = ,%PAGE%<!-- -->| noresultsheader = {{padleft:0|{{{pad|5}}}|0}}<!-- -->| count = 1 }} |/^([^{{!}}]+\{{!}}){1}([^\]]+).*/ |\2 }} | {{#if: {{{namespace|}}} | {{{namespace|}}}:}}{{{prefix|}}} | }} +1 }} | {{{pad|5}}} | 0 }}''' ---- {{#if: {{{form|}}} | {{#forminput: {{{form|}}} | {{{width|20}}} | {{{prefix|}}}<!-- -->{{padleft:<!----------- (X+1) => 0000(X+1) -->{{#expr:<!---------- 0000X+1 => (X+1) -->{{replace|<!----- "Namespace:prefix0000X" => "0000X" -->{{replace|<!-- "*[[Namespace:prefix0000X]]" => "Namespace:prefix0000X" -->{{#dpl:<!-- return pages named "*[[Namespace:prefix0000X]]" -->titleregexp =^{{{prefix|}}}[0-9]{{{{pad|5}}}}$<!--
-->| namespace = {{{namespace|}}}<!--
-->| order = descending<!--
-->| mode = userformat<!--
-->| format = ,%PAGE%<!--
-->| count = 1
}}
|/^([^{{!}}]+\{{!}}){1}([^\]]+).*/
|\2
}}
|{{#if: {{{namespace|}}} | {{{namespace|}}}:}}{{{prefix|}}}
|
}}
+1
}}
| 0
}}
| {{#if: {{{namespace|}}} | namespace = {{{namespace|}}} }}
}}
| <includeonly><strong class="error">Warning! You haven't specified a SemanticForm for page creation! Please specify a SemanticForm name.</strong></includeonly>
}}<noinclude>
{{documentation}}
</noinclude>


Cheers. ~ Michael Chidester (Contact) 15:40, 26 March 2013 (UTC)