Tags:
create new tag
, view all tags

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?


TWiki version: TWikiRelease04x00x05
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Search

-- VickiBrown - 28 Aug 2007

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list 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

 
Change status to:
Topic revision: r3 - 2007-10-03 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.