SID-00993: Formatted search syntax when calling variables
| Status: |
Answered |
TWiki version: |
4.3.2 |
Perl version: |
|
| Category: |
CategorySearch |
Server OS: |
|
Last update: |
15 years ago |
Hi,
I'm trying to create a search which will list webs based on a parameter 'OWNER', but also have the same formatting as the traditional webs bar.
The following seems to work pretty well, but how can I pass the $web result from the search to the WEBBGCOLOR call?
%SEARCH{"OWNER = TWIKI" web="all" topic="WebPreferences" nonoise="on" format=" * <img src=\"%ICONURL{web-bg}%\" alt=\"boo\" style=\"background-color:%VAR{"WEBBGCOLOR" web=\"$web\"}%\" /> $web.WebHome"}%
Many thanks for any help
--
RobMathieson - 2010-10-11
Discussion and Answer
Escape the VAR so that it runs once per hit (not once before SEARCH runs). To escape a variable, escape the percent sign, e.g.
$percntVAR{...}$percnt.
If you have many hits, repeated VAR look-up might be slow. You can address that if you store the web colors in CALC variables, and use them in the SEARCH format. Again, you need to escape the CALC with
$percntCALC{...}$percnt.
More at
VarSEARCH,
FormattedSearch,
SpreadSheetPlugin.
--
PeterThoeny - 2010-10-11
Thank you Peter.
Here is the same search with the correct syntax in case anyone wants it.
%SEARCH{"OWNER = TWIKI" web="all" topic="WebPreferences" nonoise="on" format=" * <img src=\"%ICONURL{web-bg}%\" alt=\"boo\" style=\"background-color:$percntVAR{\"WEBBGCOLOR\" web=\"$web\"}$percnt\" /> $web.WebHome"}%
--
RobMathieson - 2010-10-20
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.