Tags:
create new tag
, view all tags

Question

I have been searching for quite some time on how I can omit a heading IF there are no search results for that heading.

My search pattern:

<table>
%SEARCH{"%META:APPROVAL.*state=\"ANALYSIS\"" type="regex" topic="SprId*" nototal="on" nosearch="on" header="| <tr><h3>SPRs Under Analysis |||||| </h3></tr><tr> | *ID* | *Title*  | *Date Created* | *Created By* | *Severity* | *Assigned To* |</tr>|" format="| [[SprId$formfield(ID)][$formfield(ID)]] | $formfield(Title) | $formfield(DateCreated) | $formfield(CreatedBy) | $formfield(Severity) | $formfield(AssignedTo) |" }%
</table>

I have added the html tags that do work, but the headers are not picked up in the %TOC%.

Is there a way to modify my search to show only the heading with results and also have it show in the %TOC%?

Sharon

Environment

TWiki version: TWikiRelease04x00x04
TWiki plugins: DefaultPlugin, SpreadSheetPlugin, ApprovalPlugin, CommentPlugin, DateFieldPlugin, EditTablePlugin, InterwikiPlugin, RenderListPlugin, SectionalEditPlugin, SlideShowPlugin, SmiliesPlugin, TablePlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Search

-- SharonStrait - 30 Aug 2006

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.

You can output text conditionally by using a SpreadSheetPlugin CALC in the SEARCH format. Untested example:

%CALC{$SET(first, 1)}%
%SEARCH{ "something" nosearch="on nototal="on" format="$percntCALC{$IF($GET(first) > 0, $SET(first, 0)---++ Result$n()|*Topic*|*Summary*|$n())}$percnt|$topic|$summary|" }%

This will output a heading (---++ Result) and a table heading (|*Topic*|*Summary*|) on the first search hit.

-- PeterThoeny - 31 Aug 2006

 
Change status to:
Topic revision: r2 - 2006-08-31 - PeterThoeny
 
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.