Set Up an Infobox — Exclude Specific Attributes

Posted by ErichSteinboeck on 12 May 2008 21:14, last edited by GoVegan on 09 May 2010 06:00

Tags: conditional

rating: +4+x

How to Set Up an Infobox — Exclude Specific Attributes

Follow these steps, if you'd like to set up an infobox that doesn't display those attributes that a user marks “to be excluded”. Other attributes are displayed.

Step by Step

Create an infobox template where the code for all optional attributes (those that a user might want to exclude) is surrounded by

  • [!--{$attrib}--]@@@@” (where attrib is any infobox attribute name) and
  • [!----]”,

for example:

[[table]]
[[row]]
[[cell]]**Name:**[[/cell]][[cell]]{$name}[[/cell]]
[[/row]]

[!--{$player}--]@@@@[[row]]
[[cell]]**Player:**[[/cell]][[cell]]{$player}[[/cell]]
[[/row]][!----]

[!--{$origin}--]@@@@[[row]]
[[cell]]**Origin:**[[/cell]][[cell]]{$origin}[[/cell]]
[[/row]][!----]
[[/table]]

Note:
1. The template should not contain any Wikidot comments ([!----]) within the source code of an optional block (except the ones needed for the above structure)
2. The Wikidot syntax does not allow “[!--{$attrib}--]@@@@” to be specified between the [[table]] and the following [[row]] tag (in case you wanted to make the first row of a table optional). For a solution how to make the first row optional, see the Examples.
Putting “[!--{$attrib}--]@@@@” between an [[/row]] and a [[row]] tag is acceptable.
3. As the Wikidot parser will not accept an empty table (coded [[table]][[/table]]) as a valid syntax, hiding all rows will need an extra step — please see Examples for a solution.

On your including page, if you want to exclude an attribute, specify

attrib=@@

or, if you want this attribute to be displayed, specifiy

attrib=any-attribute-value

on the [[include infobox-template-name]] tag.

Examples

What you type … What you get …
[[include infobox name=Its name
|player=a player
|origin=The origin of this thing
]]
Name: Its name
Player: a player
Origin: The origin of this thing
[[include infobox name=Its name
|player=@@
|origin=The origin of this thing
]]

Name: Its name
Origin: The origin of this thing
[[include infobox name=Its name
|player=@@
|origin=@@
]]
Name: Its name

Need to hide first row or all rows?

If you want to

  • define the first row of a table as optional,
  • or you want to be able to hide all rows

the following extra step is needed: add an empty row (see code below) as the first row after your [[table]] tag. This will satisfy the Wikidot parser requirement “a table must contain at least one row” as this empty row will always be available.

[[table]]
[!-- Empty row to satisfy Wikidot parser --][[row style="display : none;"]][[cell]][[/cell]][[/row]]

Links

This is an application of the ideas presented in Include Part of a Page Only (Tricky Version)
There is also an alternative way to set up an Infobox — see Set Up an Infobox
This is How-to make the appearance of the photo automatic — see set-up-an-infobox-automatic-picture

Backlinks

Author

ErichSteinboeckErichSteinboeck. Please visit his/her userPage.

James KanjoJames Kanjo. Please visit his/her userPage.


Related articles

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.