Question
What I really wewant to do is
if (exists SomeTopic) {
print link to topic
else
print button using form to create topic from template
Everything up to the else can be doine using
CALC{I$F($EXISTS)...
(see
Support.IfTopicExists but I can't get the form to work in the else section: not if it's backslaehd, not if it's all on one line, no way I tried.
Is this a "bug" or a feature or a failure on my part to guess the trick?
Environment
--
VickiBrown - 23 Apr 2007
Answer
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
What does the form look like without the calc?
--
PeterThoeny - 24 Apr 2007
The form simply prints a button. If the page does exist, I want to show the link the page; if it doesn't exist, I want to proivide a button that will create it from a template. Showing the link (or not) is working, but so far I haven't found a way to
not show the button.
I could INCLUDE the form code from another page, I suppose, but there are a lot of these IFs and buttons, all slightly different, in the set.
The code as I have it now:
%CALC{$IF($EXISTS(%WEB%.%TOPIC%_ReviewForm), [[%TOPIC%_ReviewForm]], Review form %RED%is currently not available%ENDCOLOR%)}%
<form name="new" action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%INTURLENCODE{"%WEB%"}%">
<input type="hidden" name="topic" value="%TOPIC%_ReviewForm" />
<input type="hidden" value="form" name="action">
<input type="hidden" name="templatetopic" value="%WEB%.ReviewFormTemplate" />
<input type="hidden" name="topicparent" value=%TOPIC%" />
<input type="hidden" name="onlynewtopic" value="on" />
<input type="submit" value=" Create New Page" /\>
</form>
--
VickiBrown - 24 Apr 2007
If you INCLUDE the topic with the create button you can do that in the "else" part of the
$IF() by escaping the INCLUDE:
$NOP(%)INCLUDE{...}$NOP(%) is one way of doing it. In the included topic, make sure to use
%BASEWEB% and
%BASETOPIC% instead of
%WEB% and
%TOPIC%, repectively.
--
PeterThoeny - 24 Apr 2007
Thanks Peter; this works well (and is actually cleaner and more flexible than trying to shove the form code into the IF statement)
--
VickiBrown - 27 Apr 2007