Skip to main content.
home | support | download

Back to List Archive

Re: title length

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Tue Jul 01 2003 - 17:25:37 GMT
On Mon, Jun 30, 2003 at 06:52:53PM -0700, Aaron Bazar wrote:
> Good evening!
> 
> Is there a way to specify the maximum title length printed to the browser in
> swish.cgi?


Depends on what you are using for output generation.  What gets 
displayed is a, well, display issue.

So, for example, if using the Template-Toolkit method of generating 
output the title is printed like:

   [% ( item.swishtitle || item.swishdocpath )  %]

I haven't tried this, but with template toolkit you should be able to 
do:

    [% ( item.swishtitle || item.swishdocpath ) | truncate(20) %]

to truncate to 20 chars.

 http://www.template-toolkit.org/docs/plain/Manual/Filters.html#truncate_length_

If you are using the default template output (TemplateDefault.pm) then 
change this:

   my $DocTitle = $results->config('title_property') || 'swishtitle';

to something like:

   my $DocTitle = substr( $results->config('title_property') || 'swishtitle', 0, 20);
   
If you are using HTML::Template then you will probably need to truncate 
swishtitle in the TemplateHTMLTempalte module and modify the swish.tmpl 
template.

Now, if you don't want to do it in the output generation then there's a 
config you can use while indexing:

   PropertyNamesMaxLength

http://swish-e.org/current/docs/SWISH-CONFIG.html#item_PropertyNamesMaxLength


> Also, on a related topic, last week I asked about cleaning certain URLs out
> of the database. Instead of that, is there some place in the CGI script
> where I could say?
> 
> if (swishdocpath =~/domainIdoNotWant.com/) then do not print;

Yes, but the counts for total results would probably be off.  So you 
would need to adjust those, too.

So there's a bunch of places you could do that -- perhaps after  
$search->run_query; is called you could filter.  Or perhaps you could 
place the check in the add_result_to_list() filter out records -- but 
then you would need to adjust the counts as mentioned.


-- 
Bill Moseley
moseley@hank.org
Received on Tue Jul 1 17:25:45 2003