Template talk:If

From Wikipedia, the free encyclopedia
Jump to: navigation, search

[edit] Addition of pp-template

{{editprotected}}
Based on User:Wknight94 protection, suggest adding {{pp-template}} to the top of the template page Tamr007 (talk) 10:09, 10 July 2008 (UTC)

Yes check.svgY Done using the unprotected documentation subpage. {{Nihiltres|talk|log}} 13:43, 10 July 2008 (UTC)

[edit] Confused...

Could anyone explain me the usage of this template in the form of:

if condition then
  statement1
else
  statement2

I noticed that the documentation was somewhat unclear. Alexius08 is welcome to talk about his contributions. 14:13, 1 October 2008 (UTC)

I also came here looking for this. Blue Rasberry (talk) 14:16, 11 November 2011 (UTC)
There are several parser functions for this, depending on the kind of condition, see mw:Help:Extension:ParserFunctions. This Template:If is a special version preserving newlines and spaces.--Patrick (talk) 11:39, 27 December 2011 (UTC)

[edit] If in multiple comparisons

Does anyone know how to use #if: when I want to check against multiple statements? Example:

  • {{#if: {{{1}}} or {{{2}}}|do this if either condition is met|do that if condition is not met}}

Say i want to check e.g. whether 1 OR 2 is not an empty value in an infobox, how to accomplish that? The example i have does not work. There appaerently is a problem with multiple conditions? Or do i miss something? Regards, DTBone (talk) 18:18, 11 October 2008 (UTC)

The parser function does not check params, you can use both together e.g {{#if:{{{a|}}}{{{b|}}}|...}} and if any of them have values it will be true, so e.g if a=a and b=b it would be "ab", thus returns true; there is no way to tell which param returns true though in the 1 function though, this should work for most of those cases though:
  1. {{#if:{{{a|}}}{{{b|}}}|{{{a|}}}{{{b|}}}}} - this will display both if true.
  2. {{#if:{{{a|{{{b|}}}}}}|{{{a|{{{b|}}}}}}}} - this will display a if true, but if a returns false it displays b (if true)
  3. {{#if:{{{a|}}}{{{b|}}}|{{{a|{{{b|}}}}}}}} - basically the same as above, just looks lamer.
you can also nest a parser function in another:
  1. {{#if:{{{a|}}}|{{#if:{{{b|}}}|b=true|b=false}}|a=false}}
r0x timing of de response imo -- 120.17.76.106 (talk) 11:21, 24 January 2009 (UTC)
Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox