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
--
TimotheLitt - 27 Sep 2008
Answer
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.
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