Template:Ifequal

From MattWiki
Jump to: navigation, search
Documentation icon Template documentation[view] [edit] [history] [purge]
This template is used to extend the parser function '#ifeq:' to multiple tests.
  • The returned string is defined TRUE if any test pair of input parameters' satisfies as if presented in 'any single' #ifeq: test.
  • The returned value is essentially TRUE OR FALSE— garbage characters OR a null string, respectively. Thus it is suitable for testing by a simple #if:-then-else conditional on the calling page.
  • Applications are generally to display selective text for a set of pages, as in for example, a common (inter-sister project) usage page for templates, selected by specific page name cases.
  • Applications are generally to categorize differently for a group of sister sites sharing a common categorization schema, as in for example, a Wikpedia's template categories changed forms (late-winter/spring of 2007) from "common category names" with other sister projects to new forms... requiring portable templates to be adjusted by sites.
  • This template takes up to eight pairs of arguments (i.e 16 numbered parameters), tests the odd versus the even, and returns true if any pair matches using the parser function '#ifeq:'.
This can be used to test for criteria which may be satisfied by some combination of multiple magic words, such as {{SITENAME}} or {{PAGENAME}}.
example code
{{#if: {{ifequal|{{{1}}}|apples|{{{2}}}|oranges|{{{3}}}|pears}}|Yes|No}} round fruits present".
  -- returns true if any pair match so will build the string "Yes round fruits present"
  -- returns false if none match so will build the string:   "No round fruits present"
{{#if: {{#if: {{ifequal|{{{SITENAME}}}|Wikiversity|
{{{PAGENAME}}}|Aircraft|
{{{SITENAME}}}|Wikimedia commons}}||No}}
|outer if's then branch...|outer if's else branch...}}
... inverts the test so tests a condition... with an "inverted result".
--Assuming sites are either Wikiversity or Mediawiki commons returns a null string
  as seen by the second if, which then returns the Null string to the first if... 
  which will expand the specified else condition "outer if's else branch...".

See also

{{ifeqall}}
Compares one comparison string against up to 10 case strings with optional result string and default result string outputs.
{{ifeqany}}
Compares up to 24 case strings against each other with result string and default result string outputs.
{{ifor}}
Compares up to 30 comparison strings against an equal number of case strings with optional result string and default result string outputs.
  • {{=}}