TenthFleet:Infobox construction
Editor's Handbook
A guided path — read the sections in order
Start here
Style & layout
Building content
Templates
Deep dives
This page explains how the wiki's infoboxes are built, so you can add a field to an existing one or create a new one. Every infobox on this wiki follows the same simple pattern.
An infobox is really two pages working together: the template that lays out the box, and a stylesheet that colors it.
The two parts
Take {{Infobox-award}} as the model:
Template:Infobox-awardis the layout. It starts with<includeonly><templatestyles src="Infobox-award/styles.css" />, then builds a table with the classtf-abox.Template:Infobox-award/styles.cssis the look. It defines thetf-aboxclasses using the theme variables from Common.css.
How a field works
Each row of the box is wrapped so it only appears when the editor fills that field in. The pattern looks like this:
{{#if:{{{motto|}}}|
{{!}}-
{{!}} class="tf-abox-l" {{!}} '''Motto:'''
{{!}} class="tf-abox-r" {{!}} {{{motto}}}}}
Reading that plainly: if the motto field has a value, add a table row with a bold label and the value; otherwise add nothing. The {{!}} is how you write a table pipe character inside a template.
Why the pipe helper is needed
A plain
A plain
| inside a template call would be read as the start of a new parameter. The {{!}} helper tells the software you mean a literal pipe, which is what tables are made of.Adding a field to an existing infobox
- Open the template, for example
Template:Infobox-award. - Copy an existing field block and change the field name and label.
- Save, then check a page that uses the infobox to confirm the new row appears only when filled.
Creating a new infobox
- Create
Template:Infobox-yourname/styles.cssfirst, copying an existing stylesheet such asInfobox-award/styles.cssand renaming the classes. - Create
Template:Infobox-yourname, pull in the stylesheet, and build the rows with the if-guard pattern above. - Wrap the whole thing in
<includeonly>...</includeonly>so the raw markup does not show on the template's own page, and add documentation in a<noinclude>...</noinclude>block.
Start from a copy
The fastest and safest way to make a new infobox is to copy the closest existing one and adjust it, rather than starting from a blank page.
The fastest and safest way to make a new infobox is to copy the closest existing one and adjust it, rather than starting from a blank page.
| Tenth Fleet Wiki — Editor Documentation | |
|---|---|
| Start here | Contributor's guide · Introduction · Be bold · Editing basics |
| Style & layout | Manual of Style · Guide to layout · Naming conventions · Namespaces · Citing sources |
| Building content | Peerage page · Award page · Ship page · Echelon page · Order · News item |
| Templates | Template guide |
| Deep dives | Styling & theme · Infoboxes · Navboxes · Dynamic lists (DPL) · Supersession · Categories |
| Policies & Guidelines | |