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
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!