SID-01888: Conditional INCLUDE not working as expected
| Status: |
Answered |
TWiki version: |
6.0.0 |
Perl version: |
|
| Category: |
CategoryApplications |
Server OS: |
Mac OS X |
Last update: |
11 years ago |
I have the following code in my TWiki/WebTopBar
* %IF{ "$action~'*Hide*'" then="$percentINCLUDE{\"Help/HideWebLeftBar\"}$percent" }%
<form name="hideshow" action="%SCRIPTURLPATH{"view"}%/%INCLUDINGWEB%/%INCLUDINGTOPIC%" method="get">
<input type="hidden" name="hideleftbar" value="1" />
<input type="image" src="%PUBURL%/%USERSWEB%/DocumentGraphics/%IF{ "$action~'*Hide*'" then="showleftbar.png" else="hideleftbar.png" }%" title="%IF{ "$action~'*Hide*'" then="Show Left Bar" else="Hide Left Bar" }%" name="action" value="%IF{ "$action~'*Hide*'" then="Show Left Bar" else="Hide Left Bar" }%" />
</form>
The code runs when I click on the image. However, the conditional INCLUDE does not work as expected/documented.
When the first
IF fires (i.e. when
$action~'*Hide*') instead of including
Help/HideWebLeftBar, it
prints the string
$percentINCLUDE{\"Help/HideWebLeftBar\"}$percent
ref:
http://www.cfcl.com/twiki6/bin/view/System/WebTopBar
--
Vicki Brown - 2014-03-12
Discussion and Answer
Not sure. In any case, I think it is better to use some jQuery magic to toggle the sidebar. This is much faster because there is no need for a server round-trip.
--
Peter Thoeny - 2014-03-13
If I was a lot better at JQuery, that might make sense. But the code runs in Foswiki (and I like pure TWiki examples.
Given that this use of
INCLUDE is documented in
If Statements, I think this is a bug.
Bugs:Bugs/Item7463
--
Vicki Brown - 2014-03-18
It prints
$percentINCLUDE because the syntax is
$percnt, not
$percent.
--
Peter Thoeny - 2014-03-18
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.