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
--
PetricFrank - 24 Oct 2006
Answer
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