SID-00134: IF and CALC not the same in TWiki 4.1.2 and 4.2.3
| Status: |
Answered |
TWiki version: |
4.2.4 |
Perl version: |
indigoperl 5.86 |
| Category: |
SpreadSheetPlugin |
Server OS: |
WIndows 2003 server |
Last update: |
17 years ago |
Hello,
I have a web, with many pages for info on various cities. Each city has a menu page (named with the 3-character city code, plus the word Menu, like ACAMenu or SYDMenu), which a form containing the city name, country, and several other fields. In WebLeftBar, I have an if statement that decides if the current page is a city page or something else (like
WebHome, or a report page, etc). The way it decides if a page is a city page is it checks the first 3 characters of the current page, adds "Menu" to it, and sees if there's a formfield called citycode. If there is, then it includes the file with the sidemenu, if not, it doesn't show anything.
Here's the code:
%IF{ "%FORMFIELD{"citycode" web="%BASEWEB%" topic="%CALC{$REPLACE(%BASETOPIC%, 4, 100)}%Menu"}%" then="%INCLUDE{InclCitySideMenu}%"}%
This works fine in Twiki 4.1.2, but something has changed in 4.2.3/4.2.4 and it no longer works.
In 4.2.3 and 4.2.4 I get nothing if it's a city page, and this in red if it's not a city page (this is from webhome):
IF{ "" then="*[[WebMenu][]]* links:
♦City Info?
♦Clearance?
♦Concierge?
♦Crew Rec?
♦Operations/Port Infra?
♦M&A/Xfers/ShoreEx?
" }: Empty expression
I have spent an entire day trying to redo this into something that works, but I'm having no luck. I've tried using EXISTS, other IF constructions, but nothing seems to work.
I would appreciate any advice!
Thank you, Kathy
--
KathyDeLaCruz - 25 Feb 2009
Discussion and Answer
The new IF doesn't seem to evaluate a empty string as FALSE. But it should work if you compare the returned value to an empty string, represented by
'' (i.e., two single quotes):
%IF{
"'%FORMFIELD{"citycode" web="%BASEWEB%" topic="%CALC{$REPLACE(%BASETOPIC%, 4, 100)}%Menu"}%'!=''"
then="%INCLUDE{InclCitySideMenu}%"
}%
Something to watch out for: do not use a double-quote in the body of
InclCitySideMenu, else the INCLUDEd text will be truncated at that point (I would LOVE to know a work-around for that).
--
SeanCMorgan - 25 Feb 2009
Thank you, thank you, thank you!!
That works perfectly. I can't believe I spent so many hours on this, and you responded in only a few minutes. I REALLY appreciate it
--
KathyDeLaCruz - 25 Feb 2009
No problem. It helped that I knew that the form 'A'!='B' would work.
--
SeanCMorgan - 25 Feb 2009
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.