Help talk:Extension:ParserFunctions/2012

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 &amp;8201; or &amp;#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:&amp;8201; is a very thin space and &amp;#8203; is a zero-width space. Gustronico 17:47, 17 November 2011 (UTC)
 * Using zero-width spaces inside the parser function is a nice hack, but it adds another problem. If predecing cell ends with a &lt;br&gt; tag, the zero-width space character causes the preceding cell to end as &lt;br&gt;&amp;#8203; instead, which also renders an unwanted empty line to the end of the table cell. - 91.157.56.116 15:36, 7 August 2013 (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 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?

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:
 * See Help:Extension:ParserFunctions for a different example.
 * — Richardguk (talk) 18:41, 26 March 2012 (UTC)
 * — 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 : true 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. Happy ‑ melon 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: " lbs ( kg)"

The use of the template:
 * Weight:
 * Weight:

What it produces: What I WANT it to produce:
 * Weight: "2.2 lbs (1 kg)"
 * Weight: "4.41 lbs (2 kg)"
 * 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):

Any Template documentation
When you have a Enter between the category and the it will mess up the result. --Jongfeli (talk) 11:46, 2 May 2012 (UTC)
 * Bla bla 1
 * Bla bla 2
 * Bla bla 3 " lbs ( kg)"


 * 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.

Saltinbas (talk) 15:15, 14 May 2012 (UTC)
 * code =

#switch/#ifeq with apostrophes
For example, if you're matching a pagename that contains an apostrophe to the plain text version

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)