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

Search terms without zero results?

Quote Reply
Search terms without zero results?
Hi,

I'm using this global to show the last search terms, ordered by HitCount:

Code:
sub {
# Displays last 10 search terms.
my $tags = shift;
my $table = $DB->table('SearchLog');
$table->select_options ('ORDER BY HitCount DESC', 'LIMIT 5');
my $sth = $table->select;
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top10_search_loop => \@output };
}

I like to make two changes:

1. I don't like to show searches without results.
2. I like to exclude from the list search terms with more than than x chars ...

any ideas how to change the code?

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Quote Reply
Re: [kailew] Search terms without zero results? In reply to
Hi. Not sure about the second one ... but number 1 should be simple :)

Code:
sub {

# Displays last 10 search terms.
my $tags = shift;
my $table = $DB->table('SearchLog');
$table->select_options ('ORDER BY HitCount DESC', 'LIMIT 5');
my $cond = GT::SQL::Condition->new('HitCount','>','0');
my $sth = $table->select($cond) || return $GT::SQL::error


my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { top10_search_loop => \@output };
}

Hope that helps.

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: [kailew] Search terms without zero results? In reply to
Hi Andy,

thx, I'll try it ...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de
Quote Reply
Re: [kailew] Search terms without zero results? In reply to
Hi Andy,

doesn't work
all search terms, even with zero results, where diplayed ...

I have a little box on my homepage to display last search terms ... some users could do a joke and use search termas like "VVVVVVVVVVVVVVVVVVVVVVVVV" ... then the box will screwed up ... so I like to display only terms with a search result and I like to cut the maximum length of search terms displayed ...

Kai
___________________________________________
http://www.westalgarve.de
http://www.portugalforum.org
http://www.portugal-links.de