Tags:
create new tag
, view all tags

Question

I'm kinda newbie here and I was trying to make a search in my topics in which written dates are earlier or equal than a given one. I have realized that DBCacheContrib has some perl code to process that kind of searches, but I don't know how to use it.

Concretly, what I am trying to do is this:

1 User enters any date in a form field.

2 I get that number and search for every topic called "ObjectItemDetails[0-9]" which contains a field with a date earlier than the given one.

That's all. I think is quite simple but I can't find the way frown

It is OK when I search for dates equal than a given one, but when I have tried EARLIER_THAN I get no results. I thought that something like this should work, but I can't get it to work.

% SEARCH{"date EARLIER_THAN '01 Oct 2000'" ... } %

I have been looking for an example on how to use EARLIER_THAN, LATER_THAN, >=, <=, etc, but I didn't find anything. It's ok for me when it is possible to substitute the search for a regular expression but with dates and numbers it gets tricky.

Just a simple example on how to use i.e. "EARLIER_THAN" would be very appreciated 0: )

Environment

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

-- KimDeal - 26 Nov 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.

I didn't get the way yet, so I have done it using SpreadSheetPlugin. Kinda hairy, but it have worked.

-- KimDeal - 05 Dec 2007

FYI, TWiki 4.2 (to be released soon) comes with a new query language: QuerySearch.

Could you share with the community how you solved your problem with the SpreadSheetPlugin?

-- PeterThoeny - 06 Dec 2007

Sure.

I had to show a table containing project data for a given date interval and cost. In the format parameter, it should look like this:

%SEARCH{" .... " ... format="$percntCALC{$IF($VALUE($formfield(Cost)) %URLPARAM{"Sign"}% %URLPARAM{"Cost"}%,
$IF(TIME(%URLPARAM{"FromDate"})  <= $TIME($formfield(Date)), $IF($TIME(%URLPARAM{"ToDate"})  >= $TIME($formfield(Date)),
| $formfield(Name) | $formfield(Date) | $formfield(Costs) |, ), ), )}$percnt"}%

Note that Cost, FromDate, ToDate and Sign (can be =, <, >) are chosen by the user in a form.

My question refered to the use of the elements on this table shown at DBCacheContrib. How can the following tags be used in a SEARCH as a Twiki user (I mean not as part of the code for a plugin)?

Operator Result Meaning
= Boolean LHS exactly matches the regular expression on the RHS. The expression must match the whole string.
!= Boolean Inverse of =
=~ Boolean LHS contains RHS i.e. the RHS is found somewhere in the field value.
< Boolean Numeric <
> Boolean Numeric >
>= Boolean Numeric >=
<= Boolean Numeric <=
lc String Unary lower case
uc String Unary UPPER CASE
EARLIER_THAN BOOLEAN Date is earlier than the given date
LATER_THAN Boolean LHS is later than the given date (string containing a date e.g. '1 Apr 2003')
WITHIN_DAYS Boolean Date (which must be in the future) is within n working days of todays date
! Boolean Unary NOT
AND Boolean AND
OR Boolean OR
() any Bracketed subexpression

-- KimDeal - 11 Dec 2007

That is clever to filter the output of the format="" with a CALC based on the condition. You might need to output a <nop> in the ELSE part, that will avoid gaps between table rows.

I can't help you with the DBCacheContrib, I have not used it.

-- PeterThoeny - 11 Dec 2007

Thanks Peter, I haven't thought of a <nop> tag in the else part smile

-- KimDeal - 17 Dec 2007

To use those operators as a user you need to use either the FormQueryPlugin or the DBCachePlugin. I recommend the DBCachePlugin, which is better maintained. Or you can just wait for the query support in 4.2.0

-- CrawfordCurrie - 22 Dec 2007

 
Change status to:
Topic revision: r10 - 2007-12-22 - CrawfordCurrie
 
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.