Question
I am trying to spice up the standard "50 most recent changes" on my TWiki. Right now the search I have running is this:
%SEARCH{ "\.*" scope="topic" regex="on" nosearch="on" nototal="on" order="modified" reverse="on" format="| [[$topic]] | $wikiusername | $date |" limit="15" }%
However, I want the first thing printed (right now it's
[[$topic]]) to actually have the content of a formfield to be the text displayed. Something like
[[$topic][$formfield(DescriptiveName)]].
But, I also need this formfield to change, depending on the topic name. For instance, if the topic starts with "ComputerID", I want to grab a specific formfield. If the topic starts with "NetworkID", it needs to get a different formfield. And so on.
This way users see something very descriptive and relevant to them in the recent changes listing.
Any thoughts on how this might be done?
Environment
--
JasonLuttgens - 25 Apr 2007
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.
A low hanging fruit solution is to simply list the form fields, one after the other, such as
[[$topic][$formfield(DescriptiveName)$formfield(ComputerID)$formfield(NetworkID)]]. An empty string is returned if a form field does not exist. This approach assumes that the listed field names are not shared among the foms (otherwise you would get more than one form field value).
With the help of some
SpreadSheetPlugin functions you can output text conditionally. Remember to escape the CALC so that it executes once for every hit, such as
[[$topic][$percntCALC{$IF(..., $formfield(DescriptiveName), $IF(..., $formfield(ComputerID)))}$percnt]]. See
$IF(),
$EXACT(), etc.
--
PeterThoeny - 25 Apr 2007
Using calc with the IF conditionals worked out beautifully. Thanks Peter!
--
JasonLuttgens - 25 Apr 2007
one fewer open Q
--
SvenDowideit - 26 Apr 2007