PDA

View Full Version : Most popular searches hack...


claypots
04-11-2001, 08:05 PM
I've been looking for a hack like this for a long time and saw it here (lists the last ten searches):

http://www.sitepointforums.com/search.php

Did this get distributed here? Anyone know where I can get it?

Freddie Bingham
04-11-2001, 08:26 PM
The searches are stored in the search table and you can quite easily duplicate what Wayne has done.

Wayne Luke
04-11-2001, 09:41 PM
In search.php look for:

$searchforumbits=getsearchforums();

Under it add:

//WL 26-MAR-2001
//Show Last Ten Searches.
$latestsearches = $DB_site->query("SELECT searchid, querystring, username, dateline FROM search LEFT JOIN user on (search.userid=user.userid) WHERE querystring <> '' ORDER BY dateline DESC LIMIT 10");
$toggle = "#DEDEDE";
while ($latestsearch=$DB_site->fetch_array($latestsearches)) {
$latestsearch['date']=vbdate($dateformat,$latestsearch['dateline']);
$latestsearch['time']=vbdate($timeformat,$latestsearch['dateline']);
if ($toggle%2==0) {
$backcolor="#DEDEDE";
} else {
$backcolor="#EFEFEF";
}
eval("\$searchbits .= \"".gettemplate("search_latestbit")."\";");
$toggle++;
}
//End Latest Searches.


Create a template called search_latestbit:

<tr color="$backcolor">
<td><normalfont><a href="search.php?s=$session[sessionhash]&action=showresults&searchid=$latestsearch[searchid]">$latestsearch[querystring]</a></normalfont></td>
<td>$latestsearch[date]&nbsp;$latestsearch[time]</td>
</tr>


Modify your searchintro template to include:

<table bgcolor="#FFFFFF" border=0 cellpadding=4 cellspacing=1 width="100%">
<tr bgcolor="#6c6081"><TD COLSPAN=2>
<normalfont color="#afa3c5" class=thtcolor><B>Last Ten Searches</B></normalfont></td></tr>
<tr>
<tr bgcolor="#6c6081">
<td width="65%"><normalfont color="#f5d300">Search Text</normalfont></td>
<td width="35%"><normalfont color="#f5d300">Performed At:</normalfont></td>
</tr>
$searchbits
</table>

claypots
04-12-2001, 12:32 AM
Wow, thanks. I'll try this!

MrLister
04-12-2001, 12:55 AM
Thanks!!!!!! YOU DA MAN!

Wayne Luke
04-12-2001, 04:48 AM
No problem. I will share any code that doesn't jeopardize the competitiveness or financial stability of my communities.