I have come across a problem with variable expansion when using the
EditTablePlugin in combination with the
SpreadSheetPlugin. I worked around the problem by modifying TWiki::handleCommonTags, but my solution is not at all optimal.
Here is a simple example that illustrates the problem:
SERVERTIME is expanded properly and shows the date, but the top field shows %CALC{1}%.
If you modify lib/TWiki.pm and "repeat" the Plugin hook call to commonTagsHandler(), the top field will evaluate to 1. Is this the intended behavior, or just a limitation?
# Plugin Hook
$this->{plugins}->commonTagsHandler( $text, $theTopic, $theWeb, 0, $meta );
$this->{plugins}->commonTagsHandler( $text, $theTopic, $theWeb, 0, $meta );
Of course, this is not a great solution, but in my environment I don't really care about any extra processing this requires. I briefly looked over all of the outstanding issues and could not really find any mention of a problem like this, so I thought it would be good to bring this up in case a more general solution could be worked on.
When I apply the above patch to my TWiki.pm, the example above will show the number 1 in the top field of the table, instead of %CALC{1}%
--
TWiki:Main/ChristopherTracy
- 28 Jun 2008
I know your problem.
EditTablePlugin has always interpreted the TWikiVariable inside table when you edit and save resulting in the dynamic content being replaced by static.
In 4.2.0 the spec for EditTable and Table plugin was changed so the $percnt could be used to avoid the interpretation of the variables and instead the $percnt was displayed as %.
However this turned out to be a bad solution and in a later version of EditTablePlugin the original problem was finally fixed so we now have a good working feature.
The $percnt is now just a % and gets rendered AFTER the variable expansion.
The %VARIABLE% is now expanded after the TablePlugin has generated its output. But it is not expanded when you hit the edit button of an edit table.
Here is a good example of the combination of search, calc and table that now works perfectly.
%SEARCH{"AliasPlugin" format="| $percntCALC{\"$ROW()\"}$percnt | $topic |"}%
result
Search:
AliasPlugin
1 |
Item1020 |
2 |
Item1025 |
3 |
Item1135 |
4 |
Item1163 |
5 |
Item1825 |
6 |
Item1832 |
7 |
Item1877 |
8 |
Item1879 |
9 |
Item1885 |
10 |
Item2531 |
11 |
Item2965 |
12 |
Item3043 |
13 |
Item3527 |
14 |
Item3639 |
15 |
Item4131 |
16 |
Item4618 |
17 |
Item4633 |
18 |
Item4959 |
19 |
Item5371 |
20 |
Item5573 |
21 |
Item5578 |
22 |
Item5738 |
23 |
Item807 |
Number of topics: 23
And here is an edit table
%EDITTABLE{ format=" | text, 10, $percntCALC{\"$ROW()\"}$percnt |", changerows="on"}%
| %CALC{"$ROW()"}% |
| %CALC{"$ROW()"}% |
| %CALC{"$ROW()"}% |
| %CALC{"$ROW()"}% |
| %CALC{"$ROW()"}% |
result
Note how the $percnt is used to delay the % in the format but in the cells it is not needed. And when you add a row - the $percnt is expanded correctly
I think it all works great now.
No action as this is covered on another Item
--
TWiki:Main.KennethLavrsen
- 02 Aug 2008