Set Up an Infobox — Exclude Specific Attributes
rating: +2+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.

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

If you want to define the first row of a table as optional, you can use the following structure. Note that the second part of “[!--{$name}--]@@@@” (i. e. the “@@@@”) have been moved after the [[cell]] tag, but it must stay on the same line as the first part “[!--{$name}--]”.

[[table]]
[!--{$name}--][[row]][[cell]]@@@@**Name:**[[/cell]]
[[cell]]{$name}[[/cell]]
[[/row]][!-- --]
.
.
[[/table]]

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

Backlinks

Author

ErichSteinboeckErichSteinboeck. Please visit his/her userPage.

page_revision: 1, last_edited: 1210627040|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.