Re: Results

"Charles Chilcote" <[email protected]> Thu, 5 Feb 2004 16:15:15 -0500
Newsgroups gmane.comp.web.perlfect-search
Message-ID <003601c3ec2d$26fffd20$0601a8c0@CSC>
>
>Thanks for your help with indexing PDFs. It now works.
>
>Is there any way of changing the number of results per page? Also can it =
>be customized so PDFs open in a new window, ie add target=3D"_blank" to =
>the PDF's A tag?
>
>cheers
>
>

Greetings,

I also wanted the pdf links to open in a new window.  Although I imagine this isn't the prettiest code, it seems to get the job done.  

I suppose an extension list variable could be created in the conf.pl file to determine what file types would cause a new window, and then use that for the comparison instead the hard-coded "pdf" value below.

I added this code to the cast_template subroutine.  Red=New, Blue=Original 

    my $cscext = get_suffix($url);
    if($cscext ne "pdf") {
    $template->cast_loop ("results", [{rank => $first+(++$rank), 
                       url => $url,
                       highlight_link => $highlight_link,
                       visibleurl => $visible_url, 
                       title => $title, 
                       date => $date, 
                       score => $score,
                       description => $desc,
                       size => sprintf("%.0f", $sizes_db{$_}/1000) || 1,
                      }]);
    }
    else {
    my $blankpage = '" target="_blank';
    $template->cast_loop ("results", [{rank => $first+(++$rank), 
                       url => $url . $blankpage,
                       highlight_link => $highlight_link,
                       visibleurl => $visible_url, 
                       title => $title, 
                       date => $date, 
                       score => $score,
                       description => $desc,
                       size => sprintf("%.0f", $sizes_db{$_}/1000) || 1,
                      }]);    
    }


Charles Chilcote
Programmer/Analyst
Nitterhouse Concrete Products, Inc.
http://www.nitterhouse.com/Home.html