RenderTableDataPlugin
Extract and render table data in an alternate format
Main features:
- Pass a custom format to render the table data
- Choose a subsection of the table to be rendered: row and column ranges can be set
- Optionally render the data in a different topic the table is in
- Sort results on any table column
Motivation
Our intranet shows an introductory page with all new employees. Each person is listed with a picture and a personally written message. I wanted these 'person' blocks to be nicely formatted in HTML and CSS, while at the same time keeping the data very easy to update.
So data entry and data display are separated, leading to:
- less bugs caused by mistyping or messing up complex variable blocks - anyone not familiar with Foswiki can type some text in a table cell
- small display modules that can be moved around, for instance to the homepage
Limitations
The current implementation has the following caveats:
- Tables need to be uniform: merged cells (rowspans and colspans) are not supported
- Only tables created by Foswiki syntax are supported
Usage
%TABLEDATA{
web="..."
topic="..."
id="..."
format="..."
separator="..."
rows="..."
cols="..."
show="..."
preservespaces="on"
escapequotes="off"
sortdirection="descending"
sortcolumn="..."
filter="random"
beforetext="..."
aftertext="..."
}%
Any one of the parameters is optional.
Parameters
If you use Foswiki variables inside TABLEDATA parameters chances are it will mess up the variable, or the rendered html. Use format tokens to 'delay' rendering of these variables until the TABLEDATA parameters are parsed.
The format tokens are the same as with
FormattedSearch:
Examples
See also:
Sandbox.RenderTableDataPluginExample
RenderTableDataPlugin is not installed. To see the examples below follow the installation instructions.
Data from a table in this topic
%TABLE{id="thetable"}%
| ABC | DEF |
| GHI | JKL |
%TABLEDATA{
id="thetable"
format=" * $C2"
separator="$n()"
}%
Results in:
%TABLEDATA{
id="thetable"
format=" * $C2"
separator="$n()"
}%
Data from another topic
%TABLEDATA{
topic="%SYSTEMWEB%.MetaData"
rows="2.."
format=" * *$C1*
* _$C2_"
separator="$n()"
sortcolumn="1"
beforetext="---+++!! TOPICINFO $n()"
aftertext="From [[%SYSTEMWEB%.MetaData#META_TOPICINFO][MetaData]]"
}%
Results in:
%TABLEDATA{
topic="System.MetaData"
rows="2.."
format=" *
$C1
separator="$n()"
sortcolumn="1"
beforetext="*TOPICINFO* $n()"
aftertext="From
MetaData"
}%
Evaluating values
In this example links with a link label are created if a URL exists in the table row, otherwise only the title is displayed.
%TABLEDATA{
id="dates"
rows="2.."
sortcolumn="1"
sortdirection="descending"
format=" * $C1$C3(\"isempty\" then=\" $C4\" else=\" [[$C3][$C4]]\") %BR% $C2$n()"
}%
Results in:
%TABLEDATA{
id="dates"
rows="2.."
sortcolumn="1"
sortdirection="descending"
format=" * $C1$C3(\"isempty\" then=\" $C4\" else=\"
$C4\")
$C2$n()"
}%
Plugin Test
- This plugin is <span class=.
Settings
Settings are not read from this topic. To enable debug, copy the following
setting to your
SitePreferences or to the topic being debugged.
- Set RENDERTABLEDATAPLUGIN_DEBUG = 0
Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See
http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Plugin Info