Gossamer Forum
Quote Reply
Global for Search Words

Hi,
I found the following two globals from katabd, but the don't work with the links 3.2.0 search log.
Anyone who did this for 3.2.0?

Code:
Top search words:

sub {
my ($output,$db,$sth);
my $db = $DB->table('SearchLog');
$db->select_options ('ORDER BY HitCount DESC', 'LIMIT 5');
$sth = $db->select;

while (my $row = $sth->fetchrow_hashref) {
$output .= qq~*&nbsp;<a href="$CFG->{db_cgi_url}/search.cgi?query=$row->{Term}">$row->{Term}</a><br>~;
}
return $output > -1 ? join('-', $output): 'No terms yet!';

}



Code:
Last searched words:

sub {
my ($output,$db,$sth);
my $db = $DB->table('SearchLog');
$db->select_options ('ORDER BY TS DESC', 'LIMIT 5');
$sth = $db->select;

while (my $row = $sth->fetchrow_hashref) {
$output .= qq~*&nbsp;<a href="$CFG->{db_cgi_url}/search.cgi?query=$row->{Term}">$row->{Term}</a><br>~;
}
return $output > -1 ? join('-', $output): 'No terms yet!';

}
Thanks Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Global for Search Words In reply to
Give this a go:


Change SearchLog to SearchLogs
Change Term to slog_query
Quote Reply
Re: [rascal] Global for Search Words In reply to
Hi,

You would actually need to do a little bit more changing than that - but you're on the right line rascal =)

These should work:

Code:
Top search words:

sub {
my ($output,$db,$sth);
my $db = $DB->table('SearchLogs');
$db->select_options ('ORDER BY slog_count DESC', 'LIMIT 5');
$sth = $db->select;

while (my $row = $sth->fetchrow_hashref) {
$output .= qq~*&nbsp;<a href="$CFG->{db_cgi_url}/search.cgi?query=$row->{slog_query}">$row->{slog_query}</a><br>~;
}
$output ? return $output : return 'No terms yet!';

}



Code:
Last searched words:

sub {
my ($output,$db,$sth);
my $db = $DB->table('SearchLogs');
$db->select_options ('ORDER BY slog_last DESC', 'LIMIT 5');
$sth = $db->select;

while (my $row = $sth->fetchrow_hashref) {
$output .= qq~*&nbsp;<a href="$CFG->{db_cgi_url}/search.cgi?query=$row->{slog_query}">$row->{slog_query}</a><br>~;
}
$output ? return $output : return 'No terms yet!';

}

The main bits were the ORDER BY .. , as those fields differed too.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Aug 14, 2007, 8:19 AM
Quote Reply
Re: [Andy] Global for Search Words In reply to
Thanks rascal and Andy,
both globals work fine now with the built in 3.2.0 search log

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Global for Search Words In reply to
Hi,

Good to hear. I've actually made a little change to the global (mainly the last line). I think originally it was designed for a "loop" - thus the $output > -1 bit - but thats a bit obsolete really - as all you really need to do, is check if $output exists :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global for Search Words In reply to
Hi Andy,
I think I was to fast.
The global "Last Search Words" works fine
but
the global "Top Search Words" has an output, but it's not sorted right and not updated by new searches?

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] Global for Search Words In reply to
Hi,

My appologies. In the "Top Search Words" global, you need to change:

Code:
$db->select_options ('ORDER BY slog_hits DESC', 'LIMIT 5');

..should be:

Code:
$db->select_options ('ORDER BY slog_count DESC', 'LIMIT 5');

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global for Search Words In reply to
Hey Andy, you don't have to apologize. Glad to have you in this forum.
Thanks
Matthias

BTW: The global works perfect. What else :-)

Matthias
gpaed.de
Quote Reply
Re: [Andy] Global for Search Words In reply to
Andy wrote:
Code:
Top search words:

sub {
my ($output,$db,$sth);
my $db = $DB->table('SearchLogs');
$db->select_options ('ORDER BY slog_count DESC', 'LIMIT 5');
$sth = $db->select;

while (my $row = $sth->fetchrow_hashref) {
$output .= qq~*&nbsp;<a href="$CFG->{db_cgi_url}/search.cgi?query=$row->{slog_query}">$row->{slog_query}</a>
~;
}
$output ? return $output : return 'No terms yet!';

}

I' ve changed this code to:

Code:
sub {
my ($output,$db,$sth);
my $db = $DB->table('SearchLog');
$db->select_options ('ORDER BY HitCount DESC', 'LIMIT 10');
$sth = $db->select;

while (my $row = $sth->fetchrow_hashref) {
$output .= qq~*&nbsp;<a href="$CFG->{db_cgi_url}/search.cgi?query=$row->{Term}">$row->{Term}</a><br>~;
}
$output ? return $output : return 'No terms yet!';

}

Last edited by:

katakombe: Aug 22, 2007, 8:52 AM
Quote Reply
Re: [katakombe] Global for Search Words In reply to
Quote:
You can try like this too:

Not with the built in Gossamer Links Search Logger =) The code you gave works fine with the SearchLogger plugin - but won't work with the built in feature :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Global for Search Words In reply to
Smile Thanks Andy ..