b r a y d e n . o r g / Software

/ WebHome / TipsAndTricks / TWikiSearchTricks

This Web


WebHome  
Topic List  
Web Statistics 

All Webs


Books
Main
Random
Software
TWiki  

brayden.org


Home
Monthly Digest
Today's Links
Resumé
Reading List
Books RSS
Random RSS
Software RSS

Other


Dale's Blog

currently-reading
TextDrive

Using the TWiki formatted search for page aggregation.

TWiki Search Tricks

Using TWiki Search for Journal Entries

I picked this one up from Paul:Journal/WebHome .

The basic idea is quite simple: if you have an ongoing set of updates (link pages, blog entries, work notes, project notes, etc.), create small pages with a consistent and sortable naming scheme. Then create a 'master' page that uses formatted search to 'include' the most recently changed pages, in reverse chronological order. Here's a sample of the search to accomplish this:


%<nop>SEARCH{"^MyPage.*"
   web="Random"
   scope="topic"
   regex="on"
   nosearch="on"
   order="topic"
   reverse="on"
   nototal="on"
   limit="5"
   format="$text"}%

So in this example, you might have pages named MyPageYYYYMMDD, for example MyPage20120524. Then the search would select the most recent 5 such pages, based on page title, and display them.

To show the topics in order of their modification date, use order="modified" rather than order="topic" .

One note: the TWiki release of Dec 2001 and before do not support the format=$text option. To add the feature, modify Search.pm at around line 570 as follows:

   } elsif( $theFormat ) {
      # free format, added PTh 10 Oct 2001
      if( ! $text ) {
          ( $meta, $text ) = &TWiki::Store::readTopic( $thisWebName, $topic );
      }
      $tempVal =~ s/\$summary/&TWiki::makeTopicSummary( $text, $topic, $thisWebName )/geos;
      $tempVal =~ s/\$formfield\(\s*([^\)]*)\s*\)/getMetaFormField( $meta, $1 )/geos;
      $tempVal =~ s/\$pattern\(\s*(.*?\s*\.\*)\)/getTextPattern( $text, $1 )/geos;
      #
      # add the following line to get $text format to work
      $tempVal =~ s/\$text/$text/geos;
   } elsif( $noSummary ) {

The next step is to provide an easy way to create and edit the little pages. Again, Paul:Journal/LinksHome has a very nice way. You create a form with a button. The form action is to edit the page that corresponds to today's date. The SERVERTIME variable has just the right features for this. Here's an example:

<form name="new" action="% SCRIPTURLPATH%/edit% SCRIPTSUFFIX%/% WEB%/">
<input type="hidden" name="topic" size="40" value="MyPage% SERVERTIME{$year$mo$day}%" />
<input type="hidden" name="onlywikiname" value="on" />
<input type="hidden" name="topicparent" value="TWikiSearchTricks" />
<input type="submit" value=" Create/Edit Todays Entry " class="submitButton" />
</form>

In this example I inserted a space between the percent-sign and the following variable, to prevent variable expansion - if you copy/paste this, you'll need to get rid of the spaces.

You can accomplish the same result by hyperlinks, as in:


[[% SCRIPTURLPATH%/edit% SCRIPTSUFFIX%/% WEB%/MyPage% SERVERTIME{$year$mo$day}%][edit]]

-- DaleBrayden - 26 Aug 2003

 
 
Current Rev: r1.2 - 27 Aug 2003 - 00:30 GMT - DaleBrayden, Revision History:Diffs | r1.2 | > | r1.1
© 2003-2011 by the contributing authors.