Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease04x00x05
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories:  

-- VickiBrown - 23 Apr 2007

Answer

ALERT! 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.

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.

screenshot.jpg

screenshot2.jpg

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

Change status to:
Topic attachments
I Attachment History Action Size Date Who Comment
JPEGjpg screenshot.jpg r1 manage 11.9 K 2007-04-24 - 21:46 UnknownUser sample screenshot
JPEGjpg screenshot2.jpg r1 manage 12.5 K 2007-04-24 - 21:51 UnknownUser second screenshot
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2007-04-27 - VickiBrown
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.