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

Search global with / without results

Quote Reply
Search global with / without results
Is it possible to display i.e. 100 search queries

a.) with results (slog_hits > 0), descending slog_count
b.) without results (slog_hits = 0), descending slog_count

?

Many thanks in advance.
Quote Reply
Re: [katakombe] Search global with / without results In reply to
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
Quote Reply
Re: [Andy] Search global with / without results In reply to
Hello Andy!

Very nice as usual Wink

Just one more thing - how to display slog_count beside of results?

Once again, thanks.

Edited:

Hmm ... results are sorted by Last Searched time - I need them sorted by Count (total nr. of searches) instead

Last edited by:

katakombe: Aug 30, 2009, 4:21 AM
Quote Reply
Re: [katakombe] Search global with / without results In reply to
Hi,

Quote:
Just one more thing - how to display slog_count beside of results?

Just use <%slog_count%> =)

Quote:
Hmm ... results are sorted by Last Searched time - I need them sorted by Count (total nr. of searches) instead

You sure? It has ORDER BY slog_hits DESC in select_options , so shouldn't be.

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
Quote Reply
Re: [Andy] Search global with / without results In reply to
Andy wrote:

You sure? It has ORDER BY slog_hits DESC in select_options , so shouldn't be.

Hello again Andy!

I just replaced slog_hits with slog_count in searched_words_no_results and everything is OK Smile

Thank you on your time.
Quote Reply
Re: [katakombe] Search global with / without results In reply to
Ah ok - good to hear <G>

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