Tags:
create new tag
, view all tags

Question

Using %SEARCH to find and list a number of topics. Want to abbreviate the topic names - how can I extract part of the name? $pattern seems to work on the topic body, not the name - even in a topic search.

E.g. Consider: TopicLongName2000 TopicLongName2001 TopicLongName2010

Want: Important stuff: [[TopicLongName2000][2000]] [[TopicLongName2001][2001]] etc

Tried:

SEARCH{ "^TopicLongName\d\d\d\d$" type="regex" scope="topic" casesensitive="on" reverse="on" limit="10" nonoise="on" format="[[$topic][$pattern(.*?(\d\d\d\d).*)]]" separator=" " excludetopic="TopicLongName%DISPLAYTIME{"$YEAR"}%,TopicLongName%CALC{"$EVAL(%DISPLAYTIME{"$YEAR"}%+1)"}%"}%

But $pattern finds stuff in the text body. How do I restrict it to the topic name? Or is there a better way to produce these dynamic lists of abbreviated topic links?

Thanks!

Environment

TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Fedora Core 4
Web server: Apache
Perl version: 5.8.8
Client OS:  
Web Browser:  
Categories: Search

-- TimotheLitt - 27 Sep 2008

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.

See my answer to HowToShortenTopicNamesInSearchResult

-- SeanCMorgan - 27 Sep 2008

Thanks - but that doesn't seem to work for me when I have more than one EVAL in the SEARCH. Continuing in the referenced topic.

-- TimotheLitt - 28 Sep 2008

Here are the topics in the Sandbox web that end with last year:

-- SeanCMorgan - 29 Sep 2008

Thanks for the clues. Here's what I ended up with:

%CALC{$SET($ThisYear,$EVAL(%DISPLAYTIME{"$year"}%+0))}%
%CALC{$SET($NextYear,$EVAL(%DISPLAYTIME{"$year"}%+1))}%
   * Current topics %SEARCH{
   "MessyTopicName\d\d\d\d$"
   web="Sandbox"
   scope="topic"
   regex="on"
   nonoise="on"
   casesensitive="on"
   reverse="off"
   separator=" "
   nofinalnewline="on"
   format="$percntCALC{\"$IF($OR($EXACT($GET($ThisYear),$REPLACE($topic,1,$EVAL($LENGTH($topic)-4))), \
                                 $EXACT($GET($NextYear), $REPLACE($topic,1,$EVAL($LENGTH($topic)-4)))),  \
                             [[$web.$topic][$REPLACE($topic,1,$EVAL($LENGTH($topic)-4))]], <nop>)\"}$percnt"
 }% 
   * Other topics %SEARCH{  
   "MessyTopicName\d\d\d\d$"
   web="Sandbox"
   scope="topic"
   regex="on"
   nonoise="on"
   casesensitive="on"
   reverse="on"
   limit="10"
   separator=" "
   nofinalnewline="on"
   format="$percntCALC{\"$IF($OR($EXACT($GET($ThisYear),$REPLACE($topic,1,$EVAL($LENGTH($topic)-4))), \
                                 $EXACT($GET($NextYear), $REPLACE($topic,1,$EVAL($LENGTH($topic)-4)))),  \
                             <nop>, [[$web.$topic][$REPLACE($topic,1,$EVAL($LENGTH($topic)-4))]])\"}$percnt"
 }% 

-- TimotheLitt - 29 Sep 2008

 
Change status to:
Topic revision: r5 - 2008-09-29 - TimotheLitt
 
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.