Skip to main content.
home | support | download

Back to List Archive

Re: How can i change the search out put formats

From: Peter Karman <peter(at)not-real.peknet.com>
Date: Sun Feb 27 2005 - 01:51:34 GMT
efrain scribbled on 2/26/05 9:55 AM:
> Thanks Peter answer me!!
> 
> Look. I am using search.cgi, and now my question is: what must I have to
> change for get the search out put formats, that I desiere? Are there any
> example of this templates with the changes?
> 

see the perldoc in search.cgi for how to set the template path.

http://swish-e.org/docs/search.cgi.html

here's the template we use for the search results on swish-e.org. It uses 
Template Toolkit.


==============================================

<div class="search-page">
[%-

     page.title = 'Search';


     MACRO message(text) BLOCK;
         '<div class="search-message">';
         text;
         '</div>';
         page.title = text | html;
     END;

     USE myurl = url( request.myself, query=request.query,
                      metaname=request.metaname, size=request.pagesize );

     result_date = Date;  # set date format for results


     UNLESS result;
         message( "Must enter a query" );
     ELSE;

         # Show results

         message( result.message ) IF result.message;

         IF result.results.size;

             SET query_html = request.query | html;
             page.title = "[$query_html] $result.results.size results";
             PROCESS results_header;
             PROCESS next_links;
             PROCESS display_results;
             PROCESS next_links;
         ELSE;
             message( "No Results Found" );
         END;
     END;
-%]
</div>



[% BLOCK display_results %]
     <div class="search-results">

     [% FOREACH item = result.results %]
         <div class="search-result">
             [% PROCESS show_result %]
         </div>
     [% END %]
     </div>
[% END %]



[% BLOCK results_header %]
<div class="search-header">
     Results for <b>[% request.query | html %]</b><br />
     Showing page [% result.page %]
     ([% result.start +1 %] - [% (result.start + result.shown) %] of [% 
result.hits %] hits)

</div>
[% END %]




[% BLOCK next_links %]
     [% IF result.prev %]
        <a class="next" href="[% myurl( page=result.prev ) %]">Previous</a>
     [% END %]
     [% IF result.next %]
        <a class="prev" href="[% myurl( page=result.next ) %]">Next</a>
     [% END %]
[% END %]


[% BLOCK show_result %]
     [%
         SET doc_path    = item.Property('swishdocpath');
         SET is_list     = doc_path.match('/archive/');
         SET is_devel    = doc_path.match('/devel_docs/');
         SET is_docs     = doc_path.match('/docs/');
     %]

     <div class="search-title">

         [% IF is_list %]
             <span class='indxtype'>[List Archive]</span>
         [% ELSIF is_devel %]
             <span class='indxtype'>[Development Docs]</span>
         [% ELSIF is_docs %]
             <span class='indxtype'>[Docs]</span>
         [% END %]

         <a href="[% item.Property('swishdocpath') %]">
             [%  item.Property('swishtitle') || 'missing title' | 
highlight('swishtitle', item ) %]<
/a>

         <span class="search-rank"> -- rank: <b>[% item.Property('swishrank') 
%]</b></span>
     </div>

     <div class="search-description">
         [% item.Property('swishdescription') || "No description" | 
highlight('swishdescription', it
em) %]
     </div>

     <div class="search-metadata">
         Path: <a href="[% item.Property('swishdocpath') %]">
             [% item.Property('swishdocpath') | highlight('swishdocpath', item ) 
%]</a><br />
         Size: [% item.Property('swishdocsize') %] bytes<br />
         Date: [% result_date.format( item.Property('swishlastmodified')) %]<br />

         [% PROCESS show_list_links IF is_list %]

         [% IF is_devel %]
             Warning: <b>** Development Documentation **</b>
         [% END %]
     </div>

[% END %]

[% BLOCK show_list_links %]

     [%
         SET name    = item.Property('name');
         SET email   = item.Property('email');
         SET name_href = myurl( query="name=\"$name\"" );
         SET email_href = myurl( query="email=\"$email\"" );
     %]


         Poster's Name: <a href="[% name_href %]" title="All posts from this 
name">[% name | html %]
</a><br />
         Poster's Email: <a href="[% email_href %]" title="All posts from this 
email">[% email | htm
l %]</a>

[% END %]


-- 
Peter Karman  .  http://peknet.com/  .  peter(at)not-real.peknet.com
Received on Sat Feb 26 17:51:42 2005