Tags:
create new tag
, view all tags

SID-00174: Customized text display

Status: Answered Answered TWiki version: 4.2.4 Perl version: 5.8.8
Category: CommentPlugin Server OS: Windows 2003 Server Last update: 2 years ago

In my topic I have got two headers named

Errors

Updates

Im using an userdefined template named WIPForm whose contents are below

%TMPL:DEF{PROMPT:WIPForm}%<br />
|  *Type* | <select %DISABLED% name="WIPForm_type"><option>Update</option><option>Error</option></select> |
|  *Description* | <textarea %DISABLED% cols="80" rows="15" name="WIPForm_description"></textarea> |
| <input type="submit" value="Add Entry" /> ||
%TMPL:END%
%TMPL:DEF{OUTPUT:WIPForm}%
%<nop>URLPARAM{"WIPForm_description"}% <br>
------------------------------------------------------------------------------------------------------------%TMPL:END%

what I would like to see is if the value of WIPFORM_Type is Error, the contents should be posted under Errors header else it should be posted under Updates header

-- RajeshN - 09 Mar 2009

Discussion and Answer

Try this:

---++ Errors
%IF{"'%FORMFIELD{"WIPFORM_Type" format="$value"}%'='Errors'" then="%FORMFIELD{"WIPForm_description" format="$value"}%"}%

---++ Updates
%IF{"'%FORMFIELD{"WIPFORM_Type" format="$value"}%'='Updates'" then="%FORMFIELD{"WIPForm_description" format="$value"}%"}%
See IfStatements and VarFORMFIELD for details.

-- SeanCMorgan - 09 Mar 2009

I believe the CommentPlugin input template passes values along via VarURLPARAM, e.g. you can test on %URLPARAM{WIPForm_type}%

-- PeterThoeny - 09 Mar 2009

Hi Peter,

I tried with

%<nop>URLPARAM{WIPForm_type}%
, but I was not able to figure out how IF statement should be...

Can you please help ?

-- RajeshN - 10 Mar 2009

Did you look at IfStatements? In particular, see examples 3, 4 and 5.

-- SeanCMorgan - 10 Mar 2009

Hi Sean,

I checked out the IfStatements and below is my template code

WIP form

%TMPL:DEF{PROMPT:WIPForm}%<br />
|  *Where In SMART* | <input %DISABLED% type="text" size="80" name="WIPForm_where"  /> |
|  *Type* | <input %DISABLED% name="WIPForm_type" type="radio" value=1 /> *New Update* <input %DISABLED% name="WIPForm_type" type="radio" value=2 /> *Errors Fixed* |
|  *Description* | <textarea %DISABLED% cols="80" rows="15" name="WIPForm_description"></textarea> |
|  *Requested By* | <input %DISABLED% type="text" size="50" name="WIPForm_requestedby"/> |
|  *Requested Date* | <input %DISABLED% type="text" size="50" name="WIPForm_requesteddate"/> |
|  *Changed By* | <input %DISABLED% type="text" size="50" name="WIPForm_changedby"/> |
|  *Changed Date* | <input %DISABLED% type="text" size="50" name="WIPForm_changeddate"/> |
| <input type="submit" value="Add Entry" /> ||
%TMPL:END%

%TMPL:DEF{OUTPUT:WIPForm}%
%IF{ "$'URLPARAM{WIPForm_type}'='2'" then='%POS:BOTTOM%' else='%POS:BEFORE%'}%
<br> 
*%<nop>URLPARAM{"WIPForm_where"}%* <br>
%<nop>URLPARAM{"WIPForm_description"}% <br>
_Requested By:_ _%<nop>URLPARAM{"WIPForm_requestedby"}%_ <br>
_Requested Date:_  _%<nop>URLPARAM{"WIPForm_requesteddate"}%_ <br>
_Changed By:_  _%<nop>URLPARAM{"WIPForm_changedby"}%_ <br>
_Changed Date:_  _%<nop>URLPARAM{"WIPForm_changeddate"}%_ <br>
%<nop>URLPARAM{"WIPForm_type"}% <br>
-------------------------------------------------------------------------------------------------------------------------------------------
%TMPL:END%



When I use this tmpl, for some reason all the data (doesn't matter WIPForm_type = 1 or 2) entered are displayed before my comment form.

When I looked into my TWiki logs, I found there was an Warning appearing whenever this user defined form was used "IfDefinedPlugin has been disabled twiki"

Im sure that I have got my IfDefined plugin enabled...

Any guesses?

-- RajeshN - 11 Mar 2009

>Im sure that I have got my IfDefinedPlugin enabled...

That's odd, since I don't see a call to it. But you don't need it anyway, since VarIF can check for defined variables (for future reference, you can see what's installed by going to InstalledPlugins in your TWiki web (or whatever you call your =%SYSTEMWEB%).

I think the problem is with your quotes: each term should have double-quotes, except where you are doing a text comparison. Try this:

%IF{"$'URLPARAM{WIPForm_type}'='2'" then="%POS:BOTTOM%" else="%POS:BEFORE%"}%

or,

%IF{"'%URLPARAM{WIPForm_type}%'='2'" then="%POS:BOTTOM%" else="%POS:BEFORE%"}%

-- SeanCMorgan - 12 Mar 2009

Hi sean,

Both the solutions did not workout... and still the IfDefinedPlugin has been disabled twiki warning is appearing on the TWiki logs...

-- RajeshN - 13 Mar 2009

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider a subscription for support or engage one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- PeterThoeny - 2009-04-17

Change status to:

ALERT! 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.
SupportForm
Status Answered
Title Customized text display
SupportCategory CommentPlugin
TWiki version 4.2.4
Server OS Windows 2003 Server
Web server Apache 2.2.11
Perl version 5.8.8
Topic revision: r9 - 2009-04-17 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by PerlIdeas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.