Help:Tables
For a general overview of tables in wikis, see the Wikipedia entry.
Ordinary tables[edit source]
For very plain tables, the following syntax can be used. The first example separates each row and cell entry with a line break:
{| |- ! Column name 1 ! Column name 2 |- | Row 1, column 1 entry | Row 1, column 2 entry |- | Row 2, column 1 entry | Row 2, column 2 entry |}
Alternatively, cell entries can be listed on the same line.
{| |- ! Column name 1 !! Column name 2 |- | Row 1, column 1 entry || Row 1, column 2 entry |- | Row 2, column 1 entry || Row 2, column 2 entry |}
Note that the table code always begins with {|
and ends with |}
. Individual table rows are marked with |-
at the beginning and cells within a row all begin with |
, unless they are headings, in which case they begin with !
. This automatically signals that the text be in bold and centered.
Both the examples above result in the following, extremely plain table:
Column name 1 Column name 2 Row 1, column 1 entry Row 1, column 2 entry Row 2, column 1 entry Row 2, column 2 entry
Tables such as the one above can be difficult to read because the cells are not obviously separated.
Borders[edit source]
Borders help make the tables more legible. Below is an example of a very simple way to add a border. Simply add border=1
to the main table definition line as shown below:
{| border=1 |- ! Column name 1 ! Column name 2 |- | Row 1, column 1 entry | Row 1, column 2 entry |- | Row 2, column 1 entry | Row 2, column 2 entry |}
To produce this:
Column name 1 Column name 2 Row 1, column 1 entry Row 1, column 2 entry Row 2, column 1 entry Row 2, column 2 entry
Borders can also be tweaked to appear in different colours, or to be thicker or thinner. For example
{| style="border-color: #050505; border-width: 1px; border-style: solid;" |- ! Column name 1 ! Column name 2 |- | Row 1, column 1 entry | Row 1, column 2 entry |- | Row 2, column 1 entry | Row 2, column 2 entry |}
Yields this:
Column name 1 Column name 2 Row 1, column 1 entry Row 1, column 2 entry Row 2, column 1 entry Row 2, column 2 entry
There are also some predefined classes that exist on most wikis. The following example uses the class "wikitable", which puts the table header in a contrasting color and sets the border style:
{| class="wikitable" |- ! Column name 1 ! Column name 2 |- | Row 1, column 1 entry | Row 1, column 2 entry |- | Row 2, column 1 entry | Row 2, column 2 entry |}
Gives:
Column name 1 Column name 2 Row 1, column 1 entry Row 1, column 2 entry Row 2, column 1 entry Row 2, column 2 entry
Sortable tables[edit source]
Sortable tables are just like ordinary tables, but are given the additional class of "sortable". For example:
{| class="wikitable sortable" |- ! Column name 1 ! Column name 2 |- | Row 1, column 1 entry | Row 1, column 2 entry |- | Row 2, column 1 entry | Row 2, column 2 entry |}
Gives:
Column name 1 Column name 2 Row 1, column 1 entry Row 1, column 2 entry Row 2, column 1 entry Row 2, column 2 entry
Automatically generated tables[edit source]
The wiki also uses the DPL extension (DynamicPageList) to automatically generate tables from pre-existing wiki pages. These are a bit more complicated to create, but not actually difficult.
<dpl> category=food uses=Template:Infobox item include= {infobox item}:craftable,{infobox item}:hunger, {infobox item}:thirst, {infobox item}:consumption format={| class="wikitable sortable" style="width:70%"\n! style="text-align:center"|Name !! style="text-align:center"|Craftable !! style="text-align:center"|Hunger !! style="text-align:center"|Thirst !! style="text-align:center"|Other Effects,\n|-\n|[[%PAGE%]],, secseparators=\n|{{#ifeq:,|y|Yes|No}},\n||,,\n|| ,,\n|, </dpl>
This example selects all documents in the Food category, then narrows that to only documents which use the {{infobox item}}
template. It further narrows the information displayed by only using the date found in the "Craftable", "Hunger", "Thirst" and "Consumption" fields. The next line of code (beginning with format=) is regular table code as described above, with line breaks expressed by using \n
.
An example of that output is the Food page on this wiki.