Gossamer Forum
Quote Reply
Top Searches for today
Hi

I'm using Alex Search Logger plugin. At the time being I have Global which display 10 most used search terms.
Code:
sub {
my $tags = shift;
my $table = $DB->table('SearchLog');
$table->select_options ('ORDER BY HitCount DESC', 'LIMIT 10');
my $sth = $table->select;
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { TopSearches_loop => \@output };
}

How to set Global to display 10 most used search terms today?

FYI, there is two tables, SearchLog with fields ID, Term, HitCount, Results, Last_Hit and TS and table SearchLogDaily with fields ID, Term, HitCount, Results, Last_Hit and Hit_Date.

Regards.

UnReal Network
Quote Reply
Re: [deadroot] Top Searches for today In reply to
sub {
require GT::Date;

my $tags = shift;

my $today = GT::Date::date_get();
my $table = $DB->table('SearchLogDaily');
$table->select_options ('ORDER BY HitCount DESC', 'LIMIT 10');
my $sth = $table->select({Hit_Date => $today});
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { TopSearches_loop => \@output };
}
Quote Reply
Re: [afinlr] Top Searches for today In reply to
Thank you. It is much appreciated.

One question. Can this be done dynamically without using page.cgi so don't have to build whole site just to update Top Search terms for today?

UnReal Network
Quote Reply
Re: [deadroot] Top Searches for today In reply to
It depends which page you want to display it on. If you create a new template, top_searches.html, you can link to it with "/cgi-bin/page.cgi?p=top_Searches" - this will show this page dynamically within a static site. I used to do this with my home page - I showed the homepage as page.cgi but showed the rest of the site statically. Alternatively, I'm sure you could use an SSI call.
Quote Reply
Re: [afinlr] Top Searches for today In reply to
Hello afinlr ,

I test the use of the Global.

sub {
require GT::Date;
my $tags = shift;
my $today = GT::Date::date_get();
my $table = $DB->table('SearchLog');
$table->select_options ('ORDER BY HitCount DESC', 'LIMIT 10');
my $sth = $table->select({Hit_Date => $today});
my @output;
while (my $link = $sth->fetchrow_hashref) {
push (@output, $link);
}
return { TopSearches_loop => \@output };
}

But, I obtain the error.

---------------------------

A fatal error has occured:
Can't call method "fetchrow_hashref" on an undefined value at (eval 51) line 9.


Please enable debugging in setup for more details.

---------------------------
I do not have the SearchLogDaily table.

It is possible to use the Global without the table?

Thank you for your answer.

Mick

Last edited by:

mick31: Oct 31, 2003, 2:15 PM
Quote Reply
Re: [mick31] Top Searches for today In reply to
Hello,

I modified the Global but impossible one to make it work.

Somebody with an idea ?

Thank you for your assistance.

Mick
Quote Reply
Re: [mick31] Top Searches for today In reply to
Sorry - there are two versions of the SearchLogger plugin about - one of them has the Daily table and the other doesn't. If you don't have the Daily table it is not possible to do what you want. Try searching the forum for SearchLogger plugin and you should find the other version.
Quote Reply
Re: [afinlr] Top Searches for today In reply to
Hello Afinlr,

I found the bond, thank you.
http://www.gossamer-threads.com/...i?post=175351#175351

But the Global does not give a result.

There is no error message

An idea?

Thank you

Mick
Quote Reply
Re: [mick31] Top Searches for today In reply to
I'm not sure - but if you have installed the new version you should just be able to use

<%Plugins::SearchLogger::Top_Keywords ('10', 'd')%>

to show the most used search terms today (the global is included in the plugin).
The UK High Street
Quote Reply
Re: [afinlr] Top Searches for today In reply to
Hello,

I use already the line.
<%Plugins::SearchLogger::Top_Keywords ('10', 'd')%>

It gives me results without the Global.

I do not understand the use of Global ( <%search_today%> ) since the line ( <%Plugins::SearchLogger::Top_Keywords ('10', 'd')%> ) gives the results.

Thank you

Mick