To get the 100 top results, you can use:
top_searched_words
Code:
sub {
my $limit= $_[0] || 10;
my @output;
my $db = $DB->table('SearchLogs');
$db->select_options ('ORDER BY slog_hits DESC', "LIMIT $limit");
my $sth = $db->select( GT::SQL::Condition->new('slog_query','NOT LIKE','%http://%','slog_query','NOT LIKE','http://%') ) || die $GT::SQL::error;
while (my $row = $sth->fetchrow_hashref) {
push @output, $row;
}
return { search_logger_top_searched => \@output }
}
..and call with:
Code:
<%top_searched_words('100')%>
<ul>
<%loop search_logger_top_searched%>
<li><a href="<%config.db_cgi_url%>/search.cgi?query=<%GT::CGI::escape($slog_query)%>"><%GT::CGI::html_escape($slog_query)%></a></li>
<%endloop%>
</ul>
...and for ones where there were 0 results, try:
searched_words_no_results
Code:
sub {
my $limit= $_[0] || 10;
my @output;
my $db = $DB->table('SearchLogs');
$db->select_options ('ORDER BY slog_hits DESC', "LIMIT $limit");
my $sth = $db->select( GT::SQL::Condition->new('slog_query','NOT LIKE','%http://%','slog_query','NOT LIKE','http://%','slog_hits','=','0') ) || die $GT::SQL::error;
while (my $row = $sth->fetchrow_hashref) {
push @output, $row;
}
return { search_logger_no_results => \@output }
}
..and call with:
Code:
<%searched_words_no_results('100')%>
<ul>
<%loop search_logger_no_results%>
<li><a href="<%config.db_cgi_url%>/search.cgi?query=<%GT::CGI::escape($slog_query)%>"><%GT::CGI::html_escape($slog_query)%></a></li>
<%endloop%>
</ul>
Untested, but should work =)
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work! Want to give me something back for my help? Please see my
Amazon Wish List GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500) Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin |
Pre-Made Template Sets |
FREE GLinks Plugins! Compare our different Plugin packages *new* Free CSS Templates