Tags:
create new tag
view all tags

Question

I have created a FORM that includes a FORMFIELD called "Keyword" that several Topics in my web include. I would like to be able to perform a SEARCH based upon the value of the FORMFIELD{"Keyword"}, however, the syntax that I would expect to work does not work. Here is what I tried:

%SEARCH{ "%FORMFIELD{"Keyword"}%" format=" * $topic" }%

A comparable search using the Form on this page would be:

%SEARCH{ "%FORMFIELD{"SupportStatus"}%" format=" * $topic" }%

With the following result: Search: AnsweredQuestions

Number of topics: 4823

I have also tried backing out the quotes with a \, as well as backing out { and } with no luck. The SEARCH isn't inserting the value of the formfield, before performing the search. Am I using the wrong syntax or is there some way I need to force the to calculate?

I also made sure that the search page that I was using included a value for the Keyword FORMFIELD and that that keyword appeared in other topics.

Thanks in advance for your help.

Environment

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin, SpreadSheetPlugin, EditTablePlugin, TablePlugin
Server OS:  
Web server:  
Perl version:  
Client OS: MS Windows XP
Web Browser: Firefox
Categories: Search

-- DerekHansen - 09 Jun 2005

Answer

Here's the format I use for searching formfield values:

%SEARCH{"[S]upportStatus.*value\=.*[A]skedQuestions" regex="on" limit="10" format="   * $topic" nosearch="on" nototal"on"}%

with these results:

Number of topics: 1

A few notes on this approach:

  • The search string is a regular expression, so make sure to include regex="on" .
  • The brackets around first letter in search string prevents search from finding itself.
  • You can search two different form fields by putting a semi-colon after search string and then repeat with second search string using same format.

-- LynnwoodBrown - 09 Jun 2005

Thank you for the quick reply. This approach is somewhat helpful, but not as general as I was hoping for. In particular, it requires that the person running the SEARCH look up the value of the current page's Formfield (i.e., SupportStatus) and then modify the SEARCH accordingly. I was hoping to include a more general SEARCH statement that could be used on any page with the given form and did not require modification - e.g., have the SEARCH be based upon the generic formfield value (as %FORMFIELD{"SupportStatus"}% is supposed to do) rather than the specific value on a given page. Is that possible?

-- DerekHansen - 09 Jun 2005

I would like to be able to perform a SEARCH based upon the value of the FORMFIELD{"KeyWord"} which I have configured to allow multiple values. The Syntax I used is that which LynnwoodBrown has described above. However if a Topic contains two categories e.g. Development, Training the search does not find the topic when the second keyword is used as the search criteria (it does find the topic when the first keyword is used for search criteria). Below is the Code I have on my search page:

<form action="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%">
KeyWord
<select name="KeyWord" size="1" value="%URLPARAM{"KeyWord"}%">   
<option >Using Twiki</option>
<option>Development</option>
<option>Training</option>
<option>Misc</option>
</select>
<input type="submit" value="Search" />
</form>
| *Topic:* | *KeyWord:* | *Summary:* |
%SEARCH{ "[K]eyWord.*?value="%URLPARAM{"KeyWord"}%" 
format="| [[$topic]] | $formfield(KeyWord)  | $formfield(Summary) |"  
nosearch="on"  regex="on" nototal="on" }%
-- JosieMcGeever - 29 Jun 2005

Josie - The syntax I posted above should work. I use it regularly in exactly the way you describe. In your example, try substituting this search string:

[K]eyWord.*?value=.*%URLPARAM{KeyWord}%

Maybe it will help if we dissect this regex a bit. Keep in mind, it defines the whole string we're looking for and ".*" equates to "any number of any characters". So, the string it searches for is this: KeyWord(any number of characters)value=(any number of characters)KeyWord. The second ".*" should allow it to find your Category where ever it falls in a list. Does that make sense?

-- LynnwoodBrown - 29 Jun 2005

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2005-08-02 - 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-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.