Tags:
create new tag
view all tags

Question

Goal

I would like to build a news portal, which contains a news title, description and time period for how long the article is visible on the portal.

What works so far

  • User uses a form to add easily news article to the news portal
  • The form asks for titel, description and time period
  • I'm using the JSCalendarContrib plugin for selecting a time period
  • The search query shows all news articles sorted by "modified"
  • Topics will be classified

Example for a news article

---+!! Title
Description Description Description Description Description Description Description Description Description.

---++ Time Period
| Start: | 01.03.2007 |
| End: | 07.03.2007 |

Search

I'm using this search on the news portal site...
%SEARCH{ "META\:FORM.*[M]ainKlasse;[T]opicClassification.*value\=.*\"(%URLPARAM{ "qt" default="News" }%)" type="regex" regex="on" order="modified" reverse="on" scope="all" nosearch="on" nototal="on" web="Main" format="<font color=\"#92855A\" size=\"1\"> $date </font>  %BR% <img src=\"bubble.gif\" /> <b>[[$topic][$pattern(.*---[+][!][!] *([^\n\r]+) *.*)]]</b> %BR% %BR%"}%

Question

I need to extend my search on the time period. How would this look like?

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Debian 3.1
Web server: Apache
Perl version:  
Client OS: Windows
Web Browser: Firefox 2, Opera 9
Categories: Search

-- ThomasEsau - 09 Mar 2007

Answer

ALERT! 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.

Dates, especially ones in TWiki text are not nativly understood by TWiki as dates (Though some plugins like CalendarPlugin do have localised functionality to doit). There is a possiblilty of something like this in DBCachePlugin or FormQueryPlugin.

-- SvenDowideit - 28 Apr 2007

It should be possible with SpreadSheetPlugin functions. The idea is to test for the date in the format="", and to output a hit only if within time period. You need to escape the CALC so that it evaluates once per search hit. Something like:

format="$percntCALC{$IF(..., <nop>, $topic: $pattern(...))}$percnt"

A <nop> is shown if the condition is true (e.g. outside time period), else the desired content is shown. The <nop> gets removed at rendering time.

One complication is that your 07.03.2007 format is not a standard (ISO 2007-03-07 or the like), e.g. you need to extract day, month and year and rearrange it to an ISO format before you can feed it into the $TIME() function. The $SET() and $GET() functions are useful to store temporary variables.

-- PeterThoeny - 28 Apr 2007

Change status to:
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2007-04-28 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.