Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way to make a pleasing mediawiki table?

Tags:

mediawiki

I use a MediaWiki instance on a thumb drive to keep track of a ton of stuff. In the past, I've been in a hurry so I haven't had the chance to look for a nice way to make tables, so this syntax has served my purposes well:

{| border=1
...
|}

Now I want something a little nicer; I'm used to using CSS to make nicer table borders, but I'm not finding a clean way to do this syntax via MediaWiki. Basically, I want a table that looks equivalent to this HTML:

<table style="border-collapse: collapse">
    <tr>
        <td style="border: 1px solid black">one</td>
        <td style="border: 1px solid black">two</td>
    </tr>
</table>

Setting border on every cell is going to be difficult. My initial guess is I need to add a table class to a CSS file somewhere; if so, where might the appropriate file be located?

like image 770
OwenP Avatar asked Jan 28 '09 19:01

OwenP


People also ask

How to create table in MediaWiki?

You can use the Mediawiki edit toolbar to create tables. The toolbar is helpful to generate the necessary codings. Use the first button on the right of the toolbar to insert a table when editing a page.


2 Answers

Do like they do in Wikipedia: create a "prettytable" template (see source; you can skip the fancy <noinclude> stuff) where you put some HTML / CSS, e.g.:

border="1" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; 
background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"

Then use the template like this in your tables; it does a simple "include":

{| {{Prettytable}}
...
|}

The same technique can be used for styling cells. You should find plenty more examples of this in different Wikipedias (and other Wikimedia projects).

like image 122
Jonik Avatar answered Sep 24 '22 01:09

Jonik


You can customise the CSS used via pages in the MediaWiki namespace, for example, MediaWiki:Common.css. There are also skin-specific CSS pages, e.g. MediaWiki:Monobook.css, for the default skin.

like image 26
Rob Avatar answered Sep 22 '22 01:09

Rob