Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

remote_search no results on reload

Quote Reply
remote_search no results on reload
Hello world!

I have xml_search_results plugin installed.
When I use remote_search.cgi script and search for "car" it gives me good results, but when I try to search same word (car) one more time it says "No links were found containing car"

I think there is a problem in remote_search.cgi file at RED line:

sub main {
# -----------------------------------------------------------------------------
my $q = new CGI;
my $query = $q->param('query');
$query =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/ge;
print $q->header;
$q->param or return print "No search term entered.";
eval {
require LWP::Simple;
import LWP::Simple;
if ($@) {
return print "You must have LWP::Simple installed in order to use this script.";
my $content = get("$URL&query=$query") or return print "Unable to load $URL. Reason: $!";
my $item_count = 0;
my $link_results_loop;
while ($content =~ m,<item>(.*?)</item>,sg) {
my $item = $1;
my ($title,$link,$description,$link_category_id) = $item =~ m,
push @$link_results_loop => {title => $title, link => $link, description => $description, link_category_id => $link_category_id};
$item_count or return print "No links were found containing <b>$query</b> !";

open (TMP, $TEMPLATE) or return print "Unable to open template file: $TEMPLATE ($!)";
read (TMP, my $data, -s TMP);
close TMP;
print '<html><head><meta http-equiv="Content-Type" content="charset=iso-8859-2"><title>Raziskovalec</title></head><body>';
print parse_template($data, $link_results_loop);
print '</body></html>';

sub parse_template {
# Simply parse the template and replace the link loop
my ($TEMPLATE,$loop) = @_;
(ref $loop eq 'ARRAY') || return;
my ($loop_content) = $TEMPLATE =~ /<%link_loop%>(.*?)<%end_loop%>/sm;
my $result;
foreach (@$loop) {
my $tmp = $loop_content;
$tmp =~ s/<%\s*(.*?)\s*%>/(exists $_->{$1})?$_->{$1}:'';/seg;
$result .= $tmp;
$TEMPLATE =~ s/(<%link_loop%>.*?<%end_loop%>)/$result/sm;

return $result;

I wonder why it works when I search first time and dont work second time for same search term.

Quote Reply
Re: [raziskovalec] remote_search no results on reload In reply to
My answer to my question:

Plugin xml_results and plugin search_cache don't like each other.

You shoul add red line in searchcache.pl

my ($args) = shift;
if ($IN->param('xml_feed')) { return $args; }

# Do something useful here
if (!$args->{error} and !$args->{searchcache}){
my $save = {};
$save->{$_} = $args->{$_} for (@search_fields);
Quote Reply
Re: [raziskovalec] remote_search no results on reload In reply to
Does anyone know how to add paging toolbar to the remote_search.cgi? It only shows 15 results and the first page.

Quote Reply
Re: [socrates] remote_search no results on reload In reply to

I think you should add two more tags 'links_hit' and 'cats_hit' into the xml_search_results.xml, then get the remote_search.cgi parsed these values. After that you will create a paging function yourself into the remote_search.cgi.

I have created a similar plugin and it has this function. Just let me know if you need it.




Programming and creating plugins and templates