Posted by ErichSteinboeck on 12 May 2008 21:14, last edited by James Kanjo on 09 May 2010 06:00
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 … | ||||||
|
|
||||||
|
|
||||||
|
|
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
ErichSteinboeck. Please visit his/her userPage.
James Kanjo. Please visit his/her userPage.
Other(!) HowTos posted by ErichSteinboeck
- Include a Forum Thread
- Create Sortable List of Pages
- Include Part Of A Page Only (Tricky Version)
- ListPages: Automatic Header
- System Variables
- System Variables: Details
- Nested Comments
- Include With Defaults
- Module Attributes via URL
- Iframe Link
- How Many Days Does Your Wiki Exist
- Feed/FrontForum/ListPages/live template — %%date%%
- Date: How Long Ago?
- Include Part Of A Page Only
- Include Inline
- Page Count
- Direct Links to Sub-Pages of System Pages
- Set Up An Infobox





