Recent Changes - Search:

PITS main list

edit sidebar

Main sidebar



Summary: Simple table have CSS class added to facilitate customisation
Created: 2006-01-09 15:00
Status: Closed, added for 2.2.89
Category: Feature
From: Simon
Priority: 4
Version: 2.1 beta
OS: All

Description: To facilititate customistion using CSS could the table tag generated for simple tables markup please have a class added to it. eg

 <table class="wikisimpletable"

This will allow easy customisation fo simple tables without affecting complex tables and other tables generated by PmWiki.

Added variable $SimpleTableDefaultClassName, default unset. --Petko July 02, 2016, at 09:48 AM

|| width=400
||! head ||! head ||! head ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||
||  cell ||  cell ||  cell ||


In local/config.php:

  $SimpleTableDefaultClassName = "nicetable";
Sample styles, add to pub/css/local.css:
  table.nicetable {
    border: 1px solid #888;
    border-collapse: separate;
    border-spacing: 2px;
  table.nicetable tr:nth-child(odd) {
    background-color: #eee;
  table.nicetable th {
    background-color: #ccc;
    color: #800;
  table.nicetable th, table.nicetable td {
    border-right: 1px solid #888;
    border-bottom: 1px solid #888;

Old discussion

You can already do this. Just put in


I think you can use any attributes.

Here is an example:

|| class=wikisimpletable border=1 cellspacing=0 width=50%
||! alpha ||! beta ||! gamma ||! delta ||! epsilon ||
||  zeta  ||  eta  ||  theta ||  iota  ||  kappa   ||

And be sure to check out this link! FormattingSimpleTables

thanks, but I don't want all my wiki users to have to know and remember how to do this, I want to do it for them

Not only can an author specify a class for the table, but the wiki administrator can also set default styles for simple tables by changing the setting of $BlockMarkups['table'][0] in local/config.php:

    $BlockMarkups['table'][0] = '<table width="50%" class="wikisimpletable">';


tried this, but it did not work - in config.php

 $BlockMarkups['table'] = '<table class="wikisimpletable">';
in page


html generated
<hr />
<div class='vspace'></div><<tr ><td >test</td></tr>
<div class='vspace'></div><hr />

it also appears this change may affect all tables generated, not just those created from simple table markup

Thanks. But it would be simpler, and a straightforward change to make this small change available to all PmWiki administrators. Please please please add the CSS hook for simple tables. --Simon

This cannot easily be done in the Core without possibly breaking existing wikis with simple tables with a class= parameter. But you can always add a custom setting to config.php:
## ||table attributes
  "PZZ(\$GLOBALS['BlockMarkups']['table'][0] = "
    ."'<table class=\"wikisimpletable\" '.PQA(PSS('$1')).'>')

If you think this works for you, and as there haven't been any votes from other users for 4+ years, we could maybe close this entry. --Petko January 10, 2010, at 06:22 PM

Thanks. I don't see why this would break any existing wiki. This would simply be a default class added in addition to any a user declares in a class= parameter. This is similar to changes that have been made for buttons in this time frame which have made them much easier to format using local.css.

From PM on mailing list 2010-01-12

The problem is that this isn't actually "simple" nor "straightforward". PmWiki doesn't have an easy way to put a default class "in addition to any a user declares" -- as things currently exist it can either use a hard-coded one, fall back to a default, or accept the class declaration provided by the user. There's not a simple mechanism for combining classes (which, btw, I personally find to be a serious flaw in the design of CSS itself).

So, add "a default class in addition to a user-declared class" would actually require substantial code changes to the simple table markup. It also would remove the ability for users to create a simple table without having the default class in it. So, what you're describing is not at all a trivial change, and does impact existing wikis.

It's entirely possible for a wiki administrator to set a default class explicitly in config.php (the PITS comments incorrectly omit the required [0] subscript):

   $BlockMarkups['table'][0] = "<table class='wikisimpletable' width='100%'>";

This sets the default class for any simple tables that get generated, although it can be overridden by any user-supplied class. It only affect simple tables -- it doesn't change the class settings for advanced tables or other tables that PmWiki generates.

Having looked at it a bit further, I don't have a big problem with the above $BlockMarkup value being set as the default in stdmarkup.php, as long as we're clear that any user-supplied class= attribute continues to override the default class attribute, and is not in addition to it.

For what it's worth, I struggled for a couple of hours to get this to work, with no luck. Finally I realised I could define a CSS style using '#wikitext table' to do exactly what I wanted. Even better, the table style is limited to the wikitext div, so it doesn't impact on other page elements. Of course, this needs the #wikitext section to be defined in the skin... I'm not sure how standard this is. - MichaelR 12/9/2011

Edit - History - Print - Recent Changes - Search
Page last modified on December 29, 2016, at 09:18 PM