Tags:
create new tag
view all tags

Question

Given: Couple of topics with attached form. One form element is named Customer. There can be more than one topic with the same value in the field Customer.

Problem: Get uniqie list of values in the field Customer (not the list of topics !).

Use case: Fill a list of <option> elements for a list box (may be by use of the format option in %SEARCH%).

Usually i would do

%SEARCH{"name=\"MyForm\"" scope="text" excludetopic="MyTemplate" nosearch="on" format="<option>$formfield(Customer)</option>"}%

but this gives me duplicates. Also a sorted output would be nice.

Any idea how to get this done ?

Environment

TWiki version: TWikiRelease04x00x04
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin, SpreadSheetPlugin, ActionTrackerPlugin, ControlsPlugin
Server OS: Gentoo, kernel 2.6.15
Web server: Apache 2.0.55
Perl version: 5.8.8
Client OS: Windows XP, SP2
Web Browser: Mozilla
Categories: Search

-- PetricFrank - 24 Oct 2006

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.

The only solution i found up to now is to use the SpreadSheetPlugin to maipulate the search result:

<!-- Init variable -->
%CALC{$SET(customers,)}%
<!-- Fill list of items to encounter ->
%SEARCH{ "name=\"MyForm\"" scope="true" regex="on" excludetopic="MyTemplate" nototal="on" nosearch="on" newline="false" format="$percntCALC{$SET(customers,$GET(customers)$formfield(Customer),)}$percnt"}%
<!-- make the list unique -->
%CALC{$SET(customers,$LISTUNIQUE($GET(customers)))}%
<!-- enclose by optopn tags -->
%CALC{$SET(customers,$LISTMAP(<option value="$item">$item</option>,$GET(customers)))}%
<!-- remove list element separators -->
%CALC{$SET(customers,$LISTJOIN(<nop>,$GET(customers)))}%

<!-- now display the list box -->
<select name="Customer" size="1"><option value=".*">All</option>%CALC{$GET(customers)}%</select>

That is working so far, but - in my opinion - it's too complicated for the wiki idea.

Or is there a more slick solution ?

-- PetricFrank - 27 Oct 2006

Limit the search to look just in the named form field, such as %SEARCH{ "META:FIELD.*\"Customer\"" type="regex" ... }%

-- PeterThoeny - 01 Dec 2006

Change status to:
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2006-12-01 - 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.