none
[openafs-wiki.git] / TWiki / TablePlugin.mdwn
1 # <a name="Table Plugin"></a> Table Plugin
2
3 Gives extra control of table display:
4
5 - Allows sorting
6 - Changing table properties like border width, cell spacing and cell padding
7 - Changing background color for header cells
8 - Changing background color for data cells - colors can _alternate_
9 - Behaviour can be specified for a specific table using %TABLE\{...\}% or with global preferences
10
11 ## <a name="%TOPIC% Global Settings"></a> %TOPIC% Global Settings
12
13 Plugin settings are stored as preferences variables. To reference a plugin setting write <code>**%&lt;plugin&gt;\_&lt;setting&gt;%**</code>, for example, <code>**%INTERWIKIPLUGIN\_SHORTDESCRIPTION%**</code>
14
15 - One line description, shown in the [[TextFormattingRules]] topic:
16   - Set SHORTDESCRIPTION = Control attributes of tables and sorting of table columns
17
18 - Set DEBUG to 1 to get debug messages in `data/debug.txt`. Default: `0`
19   - Set DEBUG = 0
20
21 - Table border width. Default: 1
22   - Set TABLEBORDER = 1
23
24 - Table cell padding. Default: 0
25   - Set CELLPADDING = 0
26
27 - Table cell spacing. Default: 1
28   - Set CELLSPACING = 1
29
30 - Color for header cells ('\*'s around text). Default: <span>\#99CCCC</span>
31   - #Set HEADER\_BG = red
32
33 - Background color for table rows, two alternate colors. Default: <span>\#FFFFCC</span>,<span>\#FFFFFF</span>
34   - Set DATA\_BG = #FFFFCC,#FFFFFF
35
36 - Make sortable:
37   - #Set SORT = attachments
38   - Set SORT = all
39   - #Set SORT = none
40
41 ## <a name="Sorting"></a> Sorting
42
43 Click on column heading text to sort by a column. Initial column will be sorted in descending order, click again to get ascending order. The type of data in the cell is determined automatically:
44
45 - date if format is:
46   - dd MMM YYY - hh:mm
47   - dd-MMM-YY or dd-MM-YYYY (can be / or space in place of -)
48   - MMM is Jan, Feb, etc
49 - number is digits, with optional decimal point
50 - otherwise treated as text
51
52 ## <a name="Per Table Settings"></a> Per Table Settings
53
54 On line before the table use `%TABLE{...}%`:
55
56 <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1px">
57   <tr>
58     <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=0;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Argument</font></a></th>
59     <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=1;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Comment</font></a></th>
60     <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=2;table=1;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Example</font></a></th>
61   </tr>
62   <tr>
63     <td bgcolor="#ecf2f8" style=""><code>sort</code></td>
64     <td bgcolor="#ecf2f8" style=""> Set table sorting <code>on</code> or <code>off</code></td>
65     <td bgcolor="#ecf2f8" style=""><code>sort="on"</code></td>
66   </tr>
67   <tr>
68     <td bgcolor="#ffffff" style=""><code>headerbg</code></td>
69     <td bgcolor="#ffffff" style=""> Header cell background colour </td>
70     <td bgcolor="#ffffff" style=""><code>headerbg="#99CCCC"</code></td>
71   </tr>
72   <tr>
73     <td bgcolor="#ecf2f8" style=""><code>databg</code></td>
74     <td bgcolor="#ecf2f8" style=""> Data cell background colour, a comma seperated list </td>
75     <td bgcolor="#ecf2f8" style=""><code>databg="#C8CB8F,#DBDDB5"</code></td>
76   </tr>
77   <tr>
78     <td bgcolor="#ffffff" style=""><code>tableborder</code></td>
79     <td bgcolor="#ffffff" style=""> Table border width (pixels) </td>
80     <td bgcolor="#ffffff" style=""><code>tableborder="2"</code></td>
81   </tr>
82   <tr>
83     <td bgcolor="#ecf2f8" style=""><code>cellpadding</code></td>
84     <td bgcolor="#ecf2f8" style=""> Cell padding (pixels) </td>
85     <td bgcolor="#ecf2f8" style=""><code>cellpadding="0"</code></td>
86   </tr>
87   <tr>
88     <td bgcolor="#ffffff" style=""><code>cellspacing</code></td>
89     <td bgcolor="#ffffff" style=""> Cell spacing (pixels) </td>
90     <td bgcolor="#ffffff" style=""><code>cellspacing="3"</code></td>
91   </tr>
92 </table>
93
94 All default to the global setting
95
96 ## <a name="Examples"></a> Examples
97
98 Line before table: `%TABLE{sort="on" tableborder="0" cellpadding="3" cellspacing="1" headerbg="#99CCCC" databg="#C8CB8F,#DBDDB5"}%`
99
100 <table border="0" cellpadding="3" cellspacing="1" style="border-width: 0px">
101   <tr>
102     <th bgcolor="#99CCCC" maxcols="0" style=""><a href="http://localhost?sortcol=0;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Num</font></a></th>
103     <th bgcolor="#99CCCC" maxcols="0" style=""><a href="http://localhost?sortcol=1;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Status</font></a></th>
104     <th bgcolor="#99CCCC" maxcols="0" style=""><a href="http://localhost?sortcol=2;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Action</font></a></th>
105     <th bgcolor="#99CCCC" maxcols="0" style=""><a href="http://localhost?sortcol=3;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Who</font></a></th>
106     <th bgcolor="#99CCCC" maxcols="0" style=""><a href="http://localhost?sortcol=4;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">When</font></a></th>
107     <th bgcolor="#99CCCC" maxcols="0" style=""><a href="http://localhost?sortcol=5;table=2;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Progress</font></a></th>
108   </tr>
109   <tr>
110     <td bgcolor="#C8CB8F" style=""> 1 </td>
111     <td bgcolor="#C8CB8F" style=""> C </td>
112     <td bgcolor="#C8CB8F" style=""> Chose new colours </td>
113     <td bgcolor="#C8CB8F" style=""> John </td>
114     <td bgcolor="#C8CB8F" style=""> 1-Dec-02 </td>
115     <td bgcolor="#C8CB8F" style="">   </td>
116   </tr>
117   <tr>
118     <td bgcolor="#DBDDB5" style=""> 2 </td>
119     <td bgcolor="#DBDDB5" style=""> X </td>
120     <td bgcolor="#DBDDB5" style=""> Release </td>
121     <td bgcolor="#DBDDB5" style=""> John </td>
122     <td bgcolor="#DBDDB5" style=""> 1-Apr-02 </td>
123     <td bgcolor="#DBDDB5" style="">   </td>
124   </tr>
125   <tr>
126     <td bgcolor="#C8CB8F" style=""> 3 </td>
127     <td bgcolor="#C8CB8F" style="">   </td>
128     <td bgcolor="#C8CB8F" style=""> Get feedback </td>
129     <td bgcolor="#C8CB8F" style=""> Anne </td>
130     <td bgcolor="#C8CB8F" style=""> 1-Feb-02 </td>
131     <td bgcolor="#C8CB8F" style="">   </td>
132   </tr>
133   <tr>
134     <td bgcolor="#DBDDB5" style=""> 12 </td>
135     <td bgcolor="#DBDDB5" style=""> C </td>
136     <td bgcolor="#DBDDB5" style=""> Spec error handling </td>
137     <td bgcolor="#DBDDB5" style=""> Jack </td>
138     <td bgcolor="#DBDDB5" style=""> 1-Dec-02 </td>
139     <td bgcolor="#DBDDB5" style="">   </td>
140   </tr>
141   <tr>
142     <td bgcolor="#C8CB8F" style=""> 5 </td>
143     <td bgcolor="#C8CB8F" style="">   </td>
144     <td bgcolor="#C8CB8F" style=""> Abc </td>
145     <td bgcolor="#C8CB8F" style=""> John </td>
146     <td bgcolor="#C8CB8F" style="">   </td>
147     <td bgcolor="#C8CB8F" style="">   </td>
148   </tr>
149 </table>
150
151 ### <a name="Plugin Installation Instructions"></a> Plugin Installation Instructions
152
153 - Download the ZIP file from the Plugin web (see below)
154 - Unzip <code>**%TOPIC%.zip**</code> in your twiki installation directory. Content: <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1px">
155   <tr>
156     <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=0;table=3;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">File:</font></a></th>
157     <th bgcolor="#6b7f93" maxcols="0" style=""><a href="http://localhost?sortcol=1;table=3;up=0#sorted_table" rel="nofollow" title="Sort by this column"><font color="#ffffff">Description:</font></a></th>
158   </tr>
159   <tr>
160     <td bgcolor="#ecf2f8" style=""><code><b>data/TWiki/%TOPIC%.txt</b></code></td>
161     <td bgcolor="#ecf2f8" style=""> Plugin topic </td>
162   </tr>
163   <tr>
164     <td bgcolor="#ffffff" style=""><code><b>data/TWiki/%TOPIC%.txt,v</b></code></td>
165     <td bgcolor="#ffffff" style=""> Plugin topic repository </td>
166   </tr>
167   <tr>
168     <td bgcolor="#ecf2f8" style=""><code><b>lib/TWiki/Plugins/%TOPIC%.pm</b></code></td>
169     <td bgcolor="#ecf2f8" style=""> Plugin Perl module </td>
170   </tr>
171   <tr>
172     <td bgcolor="#ffffff" style=""><code><b>pub/TWiki/%TOPIC%/diamond.gif</b></code></td>
173     <td bgcolor="#ffffff" style=""> Diamond symbol </td>
174   </tr>
175   <tr>
176     <td bgcolor="#ecf2f8" style=""><code><b>pub/TWiki/%TOPIC%/down.gif</b></code></td>
177     <td bgcolor="#ecf2f8" style=""> Down arrow </td>
178   </tr>
179   <tr>
180     <td bgcolor="#ffffff" style=""><code><b>pub/TWiki/%TOPIC%/up.gif</b></code></td>
181     <td bgcolor="#ffffff" style=""> Up arrow </td>
182   </tr>
183 </table>
184 - Test if the plugin is correctly installed:
185   - Check above example if the table renders as expected
186   - Try click on heading to sort. Other tables should also be sortable
187
188 ### <a name="Plugin Info"></a> Plugin Info
189
190 <table border="1" cellpadding="0" cellspacing="0" style="border-width: 1px">
191   <tr>
192     <td align="right" bgcolor="#ecf2f8" style=""> Plugin Author: </td>
193     <td bgcolor="#ecf2f8" style="">[[TWiki/JohnTalintyre]]</td>
194   </tr>
195   <tr>
196     <td align="right" bgcolor="#ffffff" style=""> Plugin Version: </td>
197     <td bgcolor="#ffffff" style=""> 05 Jan 2002 </td>
198   </tr>
199   <tr>
200     <td align="right" bgcolor="#ecf2f8" style=""> Change History: </td>
201     <td bgcolor="#ecf2f8" style=""> 05 Jan 2002 PTh: Fixed sorting bug of cells with leading white space <br /> 06 Dec 2001 PTh: Fixed date sorting bug <br /> 03 Dec 2001 PTh: Fixed sort="off" bug and more <br /> 29 Nov 2001: PTh fixed Perl warnings <br /> 16 Nov 2001: PTh added table border, cell spacing, cell padding, gif files <br /> 07 Oct 2001: Initial version </td>
202   </tr>
203   <tr>
204     <td align="right" bgcolor="#ffffff" style=""> CPAN Dependencies: </td>
205     <td bgcolor="#ffffff" style=""> none </td>
206   </tr>
207   <tr>
208     <td align="right" bgcolor="#ecf2f8" style=""> Other Dependencies: </td>
209     <td bgcolor="#ecf2f8" style=""> none </td>
210   </tr>
211   <tr>
212     <td align="right" bgcolor="#ffffff" style=""> Perl Version: </td>
213     <td bgcolor="#ffffff" style=""> 5.0 </td>
214   </tr>
215   <tr>
216     <td align="right" bgcolor="#ecf2f8" style=""> Plugin Home: </td>
217     <td bgcolor="#ecf2f8" style=""><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%</a></td>
218   </tr>
219   <tr>
220     <td align="right" bgcolor="#ffffff" style=""> Feedback: </td>
221     <td bgcolor="#ffffff" style=""><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev</a></td>
222   </tr>
223 </table>
224
225 **_Related Topics:_** [[TWikiPreferences]], [[TWikiPlugins]]
226
227 -- [[JohnTalintyre]] - 07 Oct 2001 <br /> -- [[PeterThoeny]] - 05 Jan 2002 <br />