Difficult to embed FOREACH constructions within a SEARCH

Q: I tried to embed a FOREACH loop inside a format clause of a SEARCH and was stuck to endless problems. I would have liked to format items in a list which was a value of a field of the retrieved topics.

A: That seems to be difficult. As a workaround, consider using the SEARCH to find the relevant topics and store the list of those topic names in a local variable, e.g. as ORGS in the following example:

   * Local KWDFIELDS = %INCLUDE{"KeywordsList"}%
   * Local ORGS = %SEARCH{ "META:FORM{name=\"OrganizationForm\"};[O]rganizationType.*?value=\"Academic\"" 
   type="regex" excludetopic="*Template" nonoise="on" format="$topic" separator=", " }%

%FOREACH{"unit" in="%ORGS%"}% 
   * *[[$unit][$percntFORMFIELD{"OrganizationNameEn" topic="$unit"}$percnt]]* <br/>
   __URL:__ $percntFORMFIELD{"OrganizationURL" topic="$unit"}$percnt <br/>
   __Controlled keywords:__ $percntINCLUDE{"WebDisplayKeywordsOfUnit" NAME="$unit"}$percnt

Note that Local is about the same as Set, see TWikiVariables#Local_values_for_variables

-- KimmoKoskenniemi - 29 Nov 2007

Topic revision: r1 - 2007-11-29 - KimmoKoskenniemi
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback