Search code examples
mediawikisidebar

How do you make "infoboxes" in mediawiki?


I'm making a wiki using Mediawiki. I've seen a right side bar of each page on other wikis. Like this: http://minecraft.gamepedia.com/Diamond_Ore

The right side bar has information about the thing that the wiki post explains or what ever.

I want to know if it's possible to make that on each page, and how?


Solution

  • Wikipedia Infoboxes are just tables with a right side float and some additional style, colors, etc.

    Minimal example

    Here a minimal example floating table with 1 column (and 1 row):

    {| style="float:right; border:1px solid black"
    | My fantastic infobox
    |-
    | More info
    |}
    

    To understand that syntax, read the official documentation:

    https://www.mediawiki.org/wiki/Help:Tables

    Example with Image

    You may be surprised that, this is just a table with two columns and some rows:

    Infobox preview

    Here the code:

    {| style="float:right;border:1px solid black"
    !colspan="2" | Fantastic Page
    |-
    !colspan="2" | [[File:Example image.svg|260px]]
    |-
    ! Info
    | Stuff
    |-
    ! More Info
    | More Stuff
    |-
    ! And Info
    | Again Stuff
    |}
    

    Useful extra information:

    • if you know CSS, use CSS classes and use the extension TemplateStyle to create a dedicated page with your CSS rules
    • if you want to create a parametrized template, read the page about MediaWiki template so that you do not need anymore to manually type that table in every page, but you just express some parameters.

    Note: this is OK for the presentational side, but for the content side one should also carefully think where to store the actual data. Especially if you want to create a wiki farm. Possibilities include standard wikitext/template syntax, SemanticMediaWiki, Wikibase.