r2 - 27 Jun 2006 - 00:08:47 - ArthurClemensYou are here: TWiki >  Codev Web > FormattedSearchWithParentTopic
Tags:
, create new tag

Implemented: Formatted Search with $parent token

The FormattedSearch supports now a $parent and $parent(20) token that shows the parent topic.

Example: (works once TWiki.org is updated)

  • Write: %SEARCH{ "^%TOPIC%$" scope="topic" regex="on" nosearch="on" nototal="on" format="$parent" }%
  • Get (for WebHome):

Change is in SVN; the FormattedSearch doc is updated.

*** bu4/Search.pm       Fri Jul 23 00:14:59 2004
--- Search.pm   Mon Jul 26 19:30:38 2004
***************
*** 957,962 ****
--- 957,964 ----
              } elsif( $theFormat ) {
                  # free format, added PTh 10 Oct 2001
                  $tempVal =~ s/\$summary/&TWiki::makeTopicSummary( $text, $topic, $thisWebName )/geos;
+                 $tempVal =~ s/\$parent\(([^\)]*)\)/breakName( getMetaParent( $meta ), $1 )/geos;
+                 $tempVal =~ s/\$parent/getMetaParent( $meta )/geos;
                  $tempVal =~ s/\$formfield\(\s*([^\)]*)\s*\)/getMetaFormField( $meta, $1 )/geos;
                  $tempVal =~ s/\$formname/_getMetaFormName( $meta )/geos;
                  $tempVal =~ s/\$pattern\((.*?\s*\.\*)\)/getTextPattern( $text, $1 )/geos;
***************
*** 1105,1110 ****
--- 1107,1131 ----
  }

  #=========================
+ =pod
+
+ ---++ sub getMetaParent( $theMeta )
+
+ Not yet documented.
+
+ =cut
+
+ sub getMetaParent
+ {
+     my( $theMeta ) = @_;
+
+     my $value = "";
+     my %parent = $theMeta->findOne( "TOPICPARENT" );
+     $value = $parent{"name"} if( %parent );
+     return $value;
+ }
+
+ #=========================
  =pod

  ---++ sub getMetaFormField (  $theMeta, $theParams  )

-- PeterThoeny - 27 Jul 2004

This does not work with the current TWiki (4).

-- ArthurClemens - 27 Jun 2006

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo