Tags:
create new tag
view all tags

SID-01291: IF statement in Search format

Status: Answered Answered TWiki version: 5.0.1 Perl version: Perl 5.8
Category: CategoryAPI Server OS: Ubuntu 8.04 Last update: 12 years ago

I want to make search result, depending on form field value.

I tried:

format="%IF{"$formfield(Title)==''" then="$topic" else="$formfield(Title)"}%

I always get $topic values, should also get some formfield values.

How do i compare that formfield value?

-- BostjanTovornik - 2011-10-11

Discussion and Answer

You need to escape the IF or it gets evaluated once before the SEARCH. You also need to escape the double quotes:

format="$percntIF{\"'$formfield(Title)'=''\" then=\"$topic\" else=\"$formfield(Title)\"}$percnt

Details in FormattedSearch and IfStatements.

-- PeterThoeny - 2011-10-11

I get errors like this:

IF{ "Vprašanja in predlogi==''" else="Vprašanja in predlogi" then="VprasanjaPredlogi" }: Syntax error in 'Vprašanja in predlogi==''' at 'šanja in predlogi=='''

IF{ "==''" else="" then="WebSearch" }: Excess operators (= =) in '=='''

Is that result of state, that $formfield(Title) doesn't exist? Or what seems to be the problem...

-- BostjanTovornik - 2011-10-12

You need to compare a 'string' with another 'string', e.g. " 'a'='b' ". I fixed my example above.

-- PeterThoeny - 2011-10-12

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging 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 - 2012-01-23

      Change status to:
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.
SupportForm
Status Answered
Title IF statement in Search format
SupportCategory CategoryAPI
TWiki version 5.0.1
Server OS Ubuntu 8.04
Web server Apache
Perl version Perl 5.8
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2012-01-23 - PeterThoeny
 
  • 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-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.