Date: 14 January 2008


Assumptions: You know how to edit your local/config.php file.

1. I wanted decent tables.

2. I wanted easy to input tables.

3. I wanted my tables to have various colorings.

  • Basic pmwiki code for tables is ugly (but typical for wikis so if you want to re-use your code in a 'regular' wiki, read no further!)
  • These are the three levels of table "improvements"

(1) Decent tables - Cookbook: Advanced Table Directives

What cookbook does?

  • How to put a caption on a table using table directives?
  • How to create headers on a table using table directives?
  • Why are there more features in ordinary tables than table directives?
  • How to apply zebra formatting to tables created with table directives?
  • Can I nest tables inside of other tables?
  • Directives and abilities for horizontal and vertical zebra tables (part 3)

(2) Easy to input tables - Cookbook: Simplified Advanced Table Directives

What cookbook does?

  • Simplifies the input of the Advanced Table Directives
Briefly   (: -> [     :) -> ]   row -> r cell -> c

 :div2end :)

  • Guibutton for table with SATD (in local/config.php - check that guibuttons are enabled, add this code and adjust array number)

$GUIButtons ['advtable'] = array(700, "[table border=1 width=98%25]\\n[row]\\n[!c]Header",
'\\n[tableend]\\n', ' ', '$GUIButtonDirUrlFmt/table.gif"$[Advanced table]"');

  • Here the code for table width width=98% is written with the special code for "%" width=98%25
  • I just use the standard table gif for this so didn't need to upload anything:

(3) Visually appealing tables

  • Add these lines to your local/config.php (anywhere in the middle)
$TableCellIndexMax = 5;
$TableRowIndexMax = 2;
$TableRowAttrFmt  = "class='row\$TableRowIndex'" ;
$TableCellAttrFmt = "class='col\$TableCellCount colidx\$TableCellIndex'";

Explanation of Codes

TableCellIndexMax = 5; allows for column shading - maybe should be increased?
$TableRowIndexMax = 2; allows for zebra tables but only numbers rows "1" or "2"

  • Create or add to /pub/css/local.css the following lines (samples that I use)
/* Example Styles ********************************************** */

/* class=firstrow has shading on any heading cell (th) and is padded above/below 3px; */
/* all other cells (td) are not shaded and padded only slightly */
table.firstrow th { padding-top:3px; padding-bottom:3px; background-color:#99CCFF} 
table.firstrow td { padding-top:2px; padding-bottom:1px; }

/* class=firstrow has shading on any heading cells (th) color:#99ccff and shading on */
/* even rows (tr.row2) color:#aabbdd */
table.zebra th { background-color:#99ccff; }
table.zebra tr.row2 { background-color:#aabbdd; }

/* class=shades regular cells in first, third and fifth columns color:#ddddff; */
/* to not shade a cell, you can use ! to make it a heading cell */
table.column td.col1 { background-color:#ddddff; }
table.column td.col3 { background-color:#ddddff; }
table.column td.col5 { background-color:#ddddff; }

 Up one level

Page last modified on December 23, 2008, at 07:04 AM