[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-devel] koha top query
From: |
long_sam.tw |
Subject: |
[Koha-devel] koha top query |
Date: |
Tue, 27 Feb 2007 18:38:04 +0800 (CST) |
Koha Top query
summary:
User query something via hiddin modthod.
Keywords will recorded in databases.It will help user when he/
she query catalog.
enviroments:
koha 2.2.5 & koha 2.2.7 (templete for npl)
modfied files:
perl scripts - opac-search.pl、opac-main.pl
tmpl - opac-main.tmpl
database - create Cookie table
1. Cookie table
CREATE TABLE `cookie` (
`id` int(255) NOT NULL auto_increment,
`names` text NOT NULL,
`counts` int(255) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `blbnoidx` (`id`)
) ENGINE=MyISAM ;
2. opac-search.pl
if ($op eq "do_search") {
......
my @tags;
.....
# put into cookie
for my $count (@value) {
my $dbh=C4::Context->dbh;
$sth = $dbh->prepare("insert into cookie(names) values (?)");
$sth->execute($count) || die $sth->errstr;
}
3. opac-main.pl
my $dbh = C4::Context->dbh;
my $top="Select names,SUM(counts) \"co\" from cookie group by names order by co
desc limit 0 , 10";
my $sth=$dbh->prepare($top);
$sth->execute;
my @top;
my $top;
while (my ($names,$counts) = $sth->fetchrow_array) {
my %rows = ( searchterm => $names,
counts => $counts,
);
push @top, \%rows;
}
$sth->finish;
$template->param(top => address@hidden);
4. opac-main.tmpl
<form action="/cgi-bin/koha/opac-search.pl">
.....
<input size="27" name="value" id="value" type="text"></p>
# add
<!-- //top // -->
<p>
Top query keywords:
<!-- TMPL_LOOP name="top" -->
<a
href="/cgi-bin/koha/opac-search.pl?op=do_search&type=opac&marclist=&and_or=and&excluding=&operator=contains&value=
<!-- TMPL_VAR name="searchterm" -->"><!-- TMPL_VAR name="searchterm" --></a>
(<!-- TMPL_VAR name="counts" -->)
<!-- /TMPL_LOOP -->
5. demo site
http://lit145.lacc.fju.edu.tw
http://koha.nkes.ntct.edu.tw
http://koha.jente.edu.tw
6.chinese information
http://koha.wikispaces.com/query
___________________________________________________
您的生活即時通 - 溝通、娛樂、生活、工作一次搞定!
http://messenger.yahoo.com.tw/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-devel] koha top query,
long_sam.tw <=