See
http://twiki.org/cgi-bin/view/Support/IfTopicExists
I am trying to test for the existence of a topic, the name of which contains underbars. This fails.
For example, if I put the following statement
into topic MediaOpsProjectDetail_35_0704
:
%CALC{"$EXISTS(MediaOpsProjectDetail_35_0704)"}%
it returns 0
--
TWiki:Main/VickiBrown
- 13 Apr 2007
I've tried putting in quotes but haven't gotten anywhere.
I knw that this is, technically, not a WikiWord, but "non" WikiWords are supported by TWiki. The TOC plugin, for example, is perfectly happy to present a table of contents for MediaOpsProjectDetail_35_0704.
Code
%TOC{"MediaOpsProjectDetail_35_0704" depth="1" title="Contents"}%
%CALC{$IF($EXISTS("MediaOpsProjectDetail_35_0704"), Yes, No)}%
Result
Contents
* Summer Movies Sample
* Forms Index
* Milestones - Planning and Reviews
* Notes
No
--
TWiki:Main.VickiBrown
- 13 Apr 2007
Test if it works here:
%CALC{"$EXISTS(Item3889)"}%
results in: 1
%CALC{"$EXISTS(WebHome)"}%
results in: 1
It looks like SpreadSheetPlugin tests for wiki words.
--
TWiki:Main.ArthurClemens
- 13 Apr 2007
All
$EXISTS()
does is this:
$result = TWiki::Func::topicExists( "", $theAttr );
. I suspect that this is a bug of the core TWiki, setting form fields accordingly.
--
TWiki:Main.PeterThoeny
- 14 Apr 2007
As the
Func
documentation states, when
topicExists
is not passed a web name in the first parameter it defaults to looking up the
Main
web. In Arthur's example above, Main.Item3889 doesn't exist, but Main.WebHome does. It's doing exactly what it says on the tin.
The workaround is to specify the web in the call, e.g.
%CALC{"$EXISTS(%WEB%.Item3889)"}%
results in: 1
Resetting form fields accordingly.
CC
Perhaps the core tin says so, but the
SpreadSheetPlugin documentation does not mention it.
This should be documented with a proper example.
In any case TWiki is lacking that "topic exists" is only available through a plugin. See
Item3894.
I've updated the summary accordingly.
--
TWiki:Main.ArthurClemens
- 14 Apr 2007
It is more intuitive to default to the current web, not the Main web. We can't change the spec of
TWiki::Func::topicExists()
because this would be an incompatible change and would break other plugins.
Recommended actions:
- Add note to
TWiki::Func::topicExists()
docs that it is recommended to add the name of the current web as the first parameter.
- Fix the SpreadSheetPlugin accordingly.
--
TWiki:Main.PeterThoeny
- 14 Apr 2007
Both items are now done in SVN MAIN and Patch04x01.
--
TWiki:Main.PeterThoeny
- 15 Apr 2007
Web.Topic is working. I can't seem to make it work without the Web specification (even after installing the latest version) but perhaps I need to do something more obvious to convince TWiki to load the new files?
--
TWiki:Main.VickiBrown
- 23 Apr 2007
%22Test:%3cbr%20/%3e%20%20%20*%20%3d%%3cnop%3eCALC%7b%24EXISTS(%%3cnop%3eTOPIC%)= returns 1
" type="html"}%
--
TWiki:Main.PeterThoeny
- 07 May 2007
NOTE: Above was added via comment plugin. I was not authenticated. TWiki asked me twice for authentication, then above content was posted. This content was supposed to get posted:
Test:
-
%CALC{$EXISTS(%TOPIC%)}%
returns 1
-
%CALC{$EXISTS(%TOPIC%Xyz)}%
returns 0
--
TWiki:Main.PeterThoeny
- 07 May 2007
It works here. Vicki, please handle this as a
TWiki:Support
question. Could be related to mod_perl or speedy caching scripts.
--
TWiki:Main.PeterThoeny
- 07 May 2007