Jump to content

Help:Conditional tables

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Locke Cole (talk | contribs) at 02:33, 17 March 2006 (work in progress). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Please note: This describes a method of hiding rows or data inside templates which will, ultimately, be replaced by native syntax in the MediaWiki software. As such, please bear in mind that once the software is updated, you should cease using this method for hiding data.

The {{qif}} template (as well as a number of other templates which directly or indirectly rely on the methods used in qif) allows for conditional display of rows in table rows, columns or cells. The method is fairly straightforward, but has some limitations which are worth explanation.

Basic use

The following example shows a basic use for {{qif}}

{{qif
|test={{{variable_foo|}}}
|then=foo is set to '''{{{variable_foo}}}'''
|else=foo is ''blank''}}

Here, the {{{variable_foo}}} is checked to see if it is defined with a non-blank value. The table below shows the output from a template call (we'll call the template {{qif_example_1}}) with different values for {{{variable_foo}}}

Template call Result
{{qif_example_1}} foo is blank
{{qif_example_1|variable_foo=}} foo is blank
{{qif_example_1|variable_foo=value}} foo is set to value