MatrixPlugin
Generate a table matrix from two lists
Introduction
Generates a matrix in table form. Input are two lists, containing the values for the x and y axis. The lists may be given directly, or as TWiki variables.
In effect, it is similar to a nested use of the
FOREACH variable (see
TWiki:Plugins.ForEachPlugin
), but it will work better for complex substitutions in the cell content, since there is only one "replace". Also, it is easier to use.
Basic Usage
Using the two lists
X and
Y defined at the end of this topic, we generate an
X*Y matrix like this:
%MATRIX{
x="%X%"
y="%Y%"
xtext="Eins, Zwei, Drei"
ytext="Aa,Bb,Cc"
corner="Letter \ Digit"
cell="$x:$y"
}%
This gives
%MATRIX{ x="1,2,3" y="a,b,c" corner="Letter \ Digit" cell="$x:$y" xtext="Eins, Zwei, Drei" ytext="Aa,Bb,Cc"}%
MATRIX Parameters
The parameters prefixed with $ will be provided for the templates, whenever it makes sense from the context. In particular, in the
cell template,
$x,
$y,
$xtext and
$ytext are available.
| Name |
Description |
Template variable |
| x |
The horizontal values |
$x |
| y |
The vertical values |
$y |
| xtext |
Concomitant for x, can be used in templates |
$xtext |
| ytext |
Concomitant for y, can be used in templates |
$ytext |
| corner |
Text for the upper left corner of the matrix |
|
| xtitle |
Title template for x |
Template |
| ytitle |
Title template for y |
Template |
| cell |
Template for cell |
Template |
| verbatim |
For debugging. If true, shows generated Twiki markup |
|
Additionally, to allow delayed rendering of generated TWiki variable calls, the variable
$percnt can be used.
Example
Here is an actual example on our company's platform. For system monitoring, there is a list of systems
P09, P11, ... to watch, and for each system there are several aspects like
Dumps, tRFC,... . If something is to note about a certain aspect in a certain system, this will be noted in a topic
SystUeb(Aspect)(Pxx), where
(Aspect) is the aspect, and
(Pxx) is the specific system. Clicking on an aspect, gives all notes regarding this aspect. Clicking on a system in the headline on top of the rows, will display all information concerning this particular system.
In the bottom part of the topic, I defined the systems and aspects as TWiki variables:
With these settings, the following code generates above table.
%TABLE{sort="off" headerbg="#E0E0E0" headercolor="#4571D0"}%
%MATRIX{
x="%SYSTEME%"
y="%ARTEN%"
corner="Art \ System"
ytitle="[[SystUeb$yAllSys][$ytext]]"
xtitle="[[%TOPICURL%Pxx?sid=$x][$x]]"
ytext = "%ARTENTEXTE%"
cell="$percntIF{`istopic 'KnowHow.SystUeb$y$x'`
then=`[[KnowHow.SystUeb$y$x][$x]]`
else=`<span class='twikiNewLink'><a href='%SCRIPTURLPATH{"edit"}%/KnowHow/SystUeb$y$x?templatetopic=SystUebTemplate' rel='nofollow' title='%MAKETEXT{"Topic $y für $x anlegen"}%'>$x</a></span>`
}$percnt"
}%
Plugin Installation & Configuration
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
- For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.
- Or, follow these manual installation steps:
- Download the ZIP file from the Plugins home (see below).
- Unzip
MatrixPlugin.zip in your twiki installation directory. Content: | File: | Description: |
data/TWiki/MatrixPlugin.txt | This description |
lib/TWiki/Plugins/MatrixPlugin.pm | The extension |
- Set the ownership of the extracted directories and files to the webserver user.
- Plugin configuration and testing:
- Run the configure script and enable the plugin in the Plugins section.
- Test if the installation was successful using the example above.
Plugin Info
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Generate a table matrix from two lists
Related Topics: TWikiPlugins,
DeveloperDocumentationCategory,
AdminDocumentationCategory,
TWikiPreferences