Posted by ErichSteinboeck on 08 May 2008 19:35, last edited by GoVegan on 09 May 2010 06:00
Tags: conditional infobox optional
How to Set Up an Infobox
Follow these steps, if you'd like to set up an infobox that displays only those attributes that have a value — all other attributes are omitted.
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
- “[!--{$attribYes}-]” (where attrib is any infobox attribute name) and
- “[!-- --]”,
for example:
[[table]]
[[row]]
[[cell]]**Name:**[[/cell]][[cell]]{$name}[[/cell]]
[[/row]]
[!--{$playerYes}-][[row]]
[[cell]]**Player:**[[/cell]][[cell]]{$player}[[/cell]]
[[/row]][!-- --]
[!--{$originYes}-][[row]]
[[cell]]**Origin:**[[/cell]][[cell]]{$origin}[[/cell]]
[[/row]][!-- --]
[[/table]]
Note:
The template should not contain any Wikidot comments ([!-- … --]) within the source code of an optional block (except the ones needed for the above structure)
On your including page, if you want to have an attribute appear, specify
attribYes=- | attrib=value-of-this-attribute
on the [[include infobox-template-name …]] tag.
Attributes that are not listed on the [[include …]] tag, are not displayed.
This also means, that you can at a later time change the infobox template (e. g. add another optional attribute) without breaking all existing includes.
Examples
What you type … | What you get … | ||||||
|
|
||||||
|
|
Links
This is an application of the ideas presented in Include Part of a Page Only
There is also an alternative way to set up an Infobox — see Set Up an Infobox -- Exclude Specific Attributes
Backlinks
Author
ErichSteinboeck. Please visit his/her userPage.
Waitaminnit… "Name", "Player", "Origin"? This wasn't actually based on the Hero/VillainBox infobox from http://siliconcity.wikidot.com, surely? XD
In any case, thanks for this article! I was looking for a way to make empty value vanish from that particular table. Much appreciated! :D
Hi Fox Lee,
You deserve thanks as well. You contributed to examples of how to use wikidot lego bricks…
gerdami - Visit Handbook en Français - Rate this howto:import-simple-excel-tables-into-wikidot up!
Hi Phil Chett,
I am feeling really positive tonight… because of 2 glasses of Chimay blanche ?
gerdami - Visit Handbook en Français - Rate this howto:import-simple-excel-tables-into-wikidot up!