1 # <a name="Edit Table Plugin"></a> Edit Table Plugin
3 This plugin allows you to edit TWiki tables using edit fields and drop down boxes. Tables have an **[ Edit table ]** button if preceeded by an `%EDITTABLE{...}%` variable. Each column can be a text field, a drop down box or a row number. Multiple tables per topic can be editable, but only one at a time canbe edited.
5 ## <a name="%TOPIC% Global Settings"></a> %TOPIC% Global Settings
7 Plugin settings are stored as preferences variables. To reference a plugin setting write <code>**%<plugin>\_<setting>%**</code>, for example, <code>**%INTERWIKIPLUGIN\_SHORTDESCRIPTION%**</code>
9 - One line description, shown in the [[TextFormattingRules]] topic:
10 - Set SHORTDESCRIPTION = Edit TWiki tables using edit fields and drop down boxes.
12 - Set DEBUG to 1 to get debug messages in `data/debug.txt`. Default: `0`
15 ## <a name="Per Table Settings"></a> Per Table Settings
17 Add a `%EDITTABLE{...}%` variable just before an existing table to make it editable, or add the variable anywhere in a topic to start a new table. Parameters:
19 <table border="1" cellpadding="0" cellspacing="0">
21 <th bgcolor="#99CCCC"><strong> Parameter </strong></th>
22 <th bgcolor="#99CCCC"><strong> Comment </strong></th>
23 <th bgcolor="#99CCCC"><strong> Default </strong></th>
26 <td><code>header</code></td>
27 <td> Enable static header if <code>"on"</code>, e.g. disable editing of the first row;<br /> Else specify the header format of a new table like <code>"|*Food*|*Drink*|"</code>. </td>
28 <td> (no header) </td>
31 <td><code>format</code></td>
32 <td> The format of one row when editing the table. A cell can be a text input field, a drop down box, a fixed label, or a row number. Cell definitions: <table cellpadding="0" cellspacing="0">
34 <td valign="top">-Text input field (1 line): </td>
35 <td><code>| text, <size>, <initial value> |</code></td>
38 <td valign="top">-Textarea input field: </td>
39 <td><code>| textarea, <rows>x<columns>, <initial value> |</code></td>
42 <td valign="top">- Drop down box: </td>
43 <td><code>| select, <size>, <option 1>, <option 2>, etc |</code></td>
46 <td valign="top">- Fixed label: </td>
47 <td><code>| label, 0, <label text> |</code></td>
50 <td valign="top">- Row number: </td>
51 <td><code>| row, <offset> |</code></td>
54 <td valign="top">- Date: </td>
55 <td><code>| date, <sizet> |</code></td>
59 <td><code>"text, 16"</code> for all cells </td>
62 <td><code>changerows</code></td>
63 <td> Rows can be added and removed if <code>"on"</code>;<br /> Rows can be added but not removed if <code>"add"</code></td>
64 <td><code>"on"</code></td>
67 <td><code>include</code></td>
68 <td> Other topic defining the EDITTABLE parameters. The first %EDITTABLE% in the topic is used. This is useful if you have many topics with the same table format and you want to update the format in one place. </td>
72 <td><code>helptopic</code></td>
73 <td> Topic name containing help text shown below the table when editing a table. The %STARTINCLUDE% and %STOPINCLUDE% variables can be used in the topic to specify what is shown. </td>
74 <td> (no help text) </td>
78 **_Note:_** By default, variables in `<initial value>` (of text input field) and `<label text>` (of fixed label) get expanded when a new row is added. This can be used for example to add a timestamp to a label. You can escape characters if you do not want that:
80 <table border="1" cellpadding="0" cellspacing="0">
82 <th bgcolor="#99CCCC"><strong> Text: </strong></th>
83 <th bgcolor="#99CCCC"><strong> To Escape: </strong></th>
86 <td><code>$quot</code></td>
87 <td> Double quote (<code>"</code>). Alternatively write <code>\"</code> to escape it </td>
90 <td><code>$percnt</code></td>
91 <td> Percent sign (<code>%</code>) </td>
94 <td><code>$dollar</code></td>
95 <td> Dollar sign (<code>$</code>) </td>
98 <td><code>$nop</code> or <code>$nop()</code></td>
99 <td> Is a "no operation" </td>
103 ## <a name="Examples"></a> Examples
105 Line before table: `%EDITTABLE{ header="|*Nr*|*Text field sandbox*|*Drop down sandbox*|*Timestamp*|" format="| row, -1 | text, 20, init | select, 1, one, two, three, four | label, 0, %SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" }%` <a name="edittable1"></a>
108 <form action="http://www.dementia.org/twiki/viewauth#edittable1" method="post" name="edittable1"><input name="ettablenr" type="hidden" value="1" /> <input name="etedit" type="hidden" value="on" /><table border="1" cellpadding="0" cellspacing="0">
110 <th bgcolor="#99CCCC"><strong> Nr </strong></th>
111 <th bgcolor="#99CCCC"><strong> Text field sandbox </strong></th>
112 <th bgcolor="#99CCCC"><strong> Drop down sandbox </strong></th>
113 <th bgcolor="#99CCCC"><strong> Timestamp </strong></th>
117 <td> hello table </td>
119 <td> 26 Jun 2002 12:30 </td>
125 <td> 27 Jun 2002 12:40 </td>
127 </table><input name="etrows" type="hidden" value="3" /> <input type="submit" value="Edit table" /></form>
130 If this plugin is installed you will see an **[ Edit table ]** button above; when you click on it you get this form:
133 <table border="1" cellpadding="0" cellspacing="1">
135 <th bgcolor="#99CCCC"> Nr </th>
136 <th bgcolor="#99CCCC"> Text field sandbox </th>
137 <th bgcolor="#99CCCC"> Drop down sandbox </th>
138 <th bgcolor="#99CCCC"> Timestamp </th>
141 <td bgcolor="#FFFFFF"> 1<input name="etcell2x1" type="hidden" value="1" /></td>
142 <td bgcolor="#FFFFFF"><input name="etcell2x2" size="20" type="text" value="hello table" /></td>
143 <td bgcolor="#FFFFFF"><select name="etcell2x3" size="1"><option selected>one</option>
145 <option>three</option>
146 <option>four</option></select></td>
147 <td bgcolor="#FFFFFF"> 26 Jun 2002 12:30<input name="etcell2x4" type="hidden" value="26 Jun 2002 12:30" /></td>
150 <td bgcolor="#FFFF99"> 2<input name="etcell3x1" type="hidden" value="2" /></td>
151 <td bgcolor="#FFFF99"><input name="etcell3x2" size="20" type="text" value="" /></td>
152 <td bgcolor="#FFFF99"><select name="etcell3x3" size="1"><option>one</option>
153 <option selected>two</option>
154 <option>three</option>
155 <option>four</option></select></td>
156 <td bgcolor="#FFFF99"> 27 Jun 2002 12:40<input name="etcell3x4" type="hidden" value="27 Jun 2002 12:40" /></td>
158 </table><input name="etsave" onclick="return(false);" type="submit" value="Save table" /> <input name="etqsave" onclick="return(false);" type="submit" value="Quietsave" /> <input name="etaddrow" onclick="return(false);" type="submit" value="Add row" /> <input name="etdelrow" onclick="return(false);" type="submit" value="Delete last row" /> <input name="etcancel" onclick="return(false);" type="submit" value="Cancel" /> (demo only, these buttons do not work) </form>
160 ## <a name="Limitations and Known Issues"></a> Limitations and Known Issues
162 - This Plugin does not support TWiki table formatting like Multi-span cells (e.g. `| ... ||`) and cell justification (e.g. `| centered | right |`).
163 - There is a performance issue when editing a large table, say, with more then 50 rows.
164 - The Plugin fails if the table is at the very end of the topic (without a new line) Always ensure there is a newline after the table
165 - Variables like `%ATTACHURL%` get expanded unless they are in a label.
166 - %RED% **Warning:** %ENDCOLOR% This plugin uses undocumented functions to read, save and lock a topic. The plugin will likely break in a future TWiki release.
167 - You cannot put two %EDITTABLE% statements on the same line in the source.
168 - You can include %-vars now in select values, by quoting them with <nop>, as in %<nop>X% for %X%, say for instance: <br />`select,1,%<nop>X%,%<nop>Y%`
169 - `date` field type for the `format` parameter adds a button popping a javascript calendar to choose the date on browsers supporting it. It uses the nice **Mishoo DHTML calendar** at <http://dynarch.com/mishoo/calendar.epl>, that should be included in Cairo release, or see TWiki:Codev/JavaScriptDatePickerForForm for installing it on Beijing Release
171 ## <a name="Plugin Installation Instructions"></a> Plugin Installation Instructions
173 - Download the ZIP file from the Plugin web (see below)
174 - Unzip <code>**%TOPIC%.zip**</code> in your twiki installation directory. Content: <table border="1" cellpadding="0" cellspacing="0">
176 <th bgcolor="#99CCCC"><strong> File: </strong></th>
177 <th bgcolor="#99CCCC"><strong> Description: </strong></th>
180 <td><code><b>data/TWiki/%TOPIC%.txt</b></code></td>
181 <td> Plugin topic </td>
184 <td><code><b>data/TWiki/%TOPIC%.txt,v</b></code></td>
185 <td> Plugin topic repository </td>
188 <td><code><b>lib/TWiki/Plugins/%TOPIC%.pm</b></code></td>
189 <td> Plugin Perl module </td>
192 - The plugin depends on the `viewauth` script to authenticate the user. As described in [[TWikiAccessControl]], copy the `view` script to `viewauth` (or better, create a symbolic link) and add `viewauth` to the list of authenticated scripts in the `.htaccess` file.
193 - Test if the plugin is correctly installed:
194 - Check above example if there is an **[ Edit table ]** button below the table in above example
195 - Click on **[ Edit table ]**, make changes and save the table
197 ## <a name="Plugin Info"></a> Plugin Info
199 <table border="1" cellpadding="0" cellspacing="0">
201 <td align="right"> Plugin Author: </td>
202 <td>[[TWiki/PeterThoeny]]</td>
205 <td align="right"> Plugin Version: </td>
206 <td> 16 Oct 2003 </td>
209 <td align="right"> Change History: </td>
213 <td align="right"> 16 Oct 2003: </td>
214 <td> small typo fixed (garbled if ---+ header on top) </td>
217 <td align="right"> 15 Oct 2003: </td>
218 <td> new date field type with javascript calendar - CN </td>
221 <td align="right"> 14 Oct 2003: </td>
222 <td> docfix: the documentation page was an old one - CN </td>
225 <td align="right"> 13 Oct 2003: </td>
226 <td> bugfix: %-vars in select were resetted to first on add/del row - CN </td>
229 <td align="right"> 18 Sep 2003: </td>
230 <td><strong>incompatibility:</strong> changed default of <code>changerows</code> to =on=<br /> support for %-vars, Quietsave for saving without notification, all other fixes in Dev topic integrated - CN </td>
233 <td align="right"> 08 Nov 2002: </td>
234 <td> Prevent variable expansion in label text; added escape characters </td>
237 <td align="right"> 27 Jun 2002: </td>
238 <td> New <code>helptopic</code> parameter </td>
241 <td align="right"> 26 Jun 2002: </td>
242 <td> Support for variables in included EDITTABLE parameters; fixed problem with HTML in cells </td>
245 <td align="right"> 21 May 2002: </td>
246 <td> Added fixed label format; new <code>changerows="add"</code> parameter </td>
249 <td align="right"> 27 Apr 2002: </td>
250 <td> Fixed bug where text after a double quote in a cell disappeared </td>
253 <td align="right"> 18 Apr 2002: </td>
254 <td> Fixed bug where table was breaking when pasting multiple lines into an edit field using Netscape on Unix </td>
257 <td align="right"> 08 Apr 2002: </td>
258 <td> Check for change permission and edit lock of topic </td>
261 <td align="right"> 05 Apr 2002: </td>
262 <td> Initial version </td>
265 <td align="right"> CPAN Dependencies: </td>
269 <td align="right"> Other Dependencies: </td>
273 <td align="right"> Perl Version: </td>
277 <td align="right"> Plugin Home: </td>
278 <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%</a></td>
281 <td align="right"> Feedback: </td>
282 <td><a href="http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev" target="_top">http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev</a></td>
286 **_Related Topics:_** [[TWikiPreferences]], [[TWikiPlugins]]
288 -- [[PeterThoeny]] - 08 Nov 2002