Question
I have a set of TWiki project pages with an attached TWiki form. One of the form fields is a project status, with value selections: Open, In Progress, On Hold, Closed.
I also have an HTML form in which a user can select or enter various values and, upon clicking submit, see the results of a TWIki SEARCH showing all project pages that match.
e.g. the search does this
search="META:FIELD.*?ProjectStatus.*?%URLPARAM{"qStat"}%.*;...
What I
want to do is this:
- If the user DOESN'T select a status, the default search should only present only Open or In Progress projects.
- If the user DOES choose a status, the search should look for the chosen status.
I'm having no difficulty searching only for Open or In Progress
search="META:FIELD.*?ProjectStatus.*?(Open|Progress).*;...
but the only way I've found to say "search on qStat if it's set and otherwise only on Open or In Progress" is to duplicate the SEARCH code and wrap it in
IFDEFINED.
%IFDEFINEDTHEN{"%URLPARAM{"qStat"}%" }%
%TABLE{sort="off"}%
|*View, edit*|*Project*|*Product Group*|...|
%SEARCH{search="META:FIELD.*?ProjectClassification.*?%URLPARAM{"qStat"}%.*;META:FIELD.*?ProjectName..." }%
%ELSEDEFINED%
%TABLE{sort="off"}%
|*View, edit*|*Project*|*Product Group*|...|
%SEARCH{search="META:FIELD.*?ProjectClassification.*?(Open|Progress).*;META:FIELD.*?ProjectName..." }%
format="| [[$topic]] ... |" }%
%FIDEFINED%
I hate duplicating code. Is there anything more "compact" I can do?
--
VickiBrown - 28 Aug 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.
Hm, can't this be done by a parametrized INCLUDE with a default value specified (didn't try, just guessing).
--
FranzJosefGigler - 29 Aug 2007
Sorry, closing this after more than 30 days of inactivity. Please feel free to reopen the question.
--
PeterThoeny - 03 Oct 2007