Set Up An Infobox

Posted by ErichSteinboeck on 08 May 2008 19:35, last edited by GoVegan on 09 May 2010 06:00

: conditional infobox optional

rating: +15

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 …
 [[include infobox name=Its name
| playerYes=- | player=a player
| originYes=- | origin=The origin of this thing
]]
Name: Its name
Player: a player
Origin: The origin of this thing
 [[include infobox name=Its name]]
]]
Name: Its name

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 ErichSteinboeck . Please visit his/her userPage.


Related articles

Comments

That Looks Familiar...
Fox Lee Fox Lee 16 Jul 2008 23:06

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

by Fox Lee Fox Lee , 16 Jul 2008 23:06
Re: That Looks Familiar...
gerdami gerdami 18 Jul 2008 18:10

Hi Fox Lee,
You deserve thanks as well. You contributed to examples of how to use wikidot lego bricks…

by gerdami gerdami , 18 Jul 2008 18:10
Re: That Looks Familiar...
gerdami gerdami 18 Jul 2008 18:13

Hi Phil Chett Phil Chett ,
I am feeling really positive tonight… because of 2 glasses of Chimay blanche ?

by gerdami gerdami , 18 Jul 2008 18:13
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).
Notify administrators if there is objectionable content in this page.
Something does not work as expected? Find out what you can do.
General Wikidot.com documentation and help section.
Wikidot.com Terms of Service - what you can, what you should not etc.
Wikidot.com Privacy Policy.

AltStyle によって変換されたページ (->オリジナル) /