Show Latest Searches of the entire site

Rosamunda - October 22, 2006 - 01:06

Hello there!

I´ve searched at the forum and handbooks for a way to show the latest searches of the entire site.
It would be nice to show the last X searches in a row, in a block...

But didn´t find the answer yet... and I dunno how to do it myself...

Any help? ideas?

Thanks in advance!!!!!!!

Rosamunda

All searchs are logged via

pwolanin - October 22, 2006 - 01:13

All searchs are logged via watchdog:

http://api.drupal.org/api/4.7/function/watchdog

check your logs- it's allready visible there. So, a quick and dirty method would be to pull the X most recent "search" items out of the watchdog table.

Rosamunda, Use the

newms - October 22, 2006 - 06:59

Rosamunda,
Use the zeitgeist module.

newms

Thanks!!

Rosamunda - October 22, 2006 - 11:30

A piece of cake :-) loved it

Rosamunda
Buenos Aires | Argentina
www.ligadelconsorcista.org

Last Searchs in a block (search + fastsearch)

adminfor@inforo... - September 19, 2008 - 11:54

As far as I know, fastsearches are not managed by zeitgeist, so, a simple snippet may solve showing last searches from watchdog file.

This example has no "distinct", but you can add it after the "select" in order to show no repetitions. Nevertheless, distinct will use a little more resources due to use of an sql internal temporary table.

Another thing, 7200 represents seconds, in this case, 2 hours, you can change it if needed. DON'T FORGET to check if you have an auxiliary TIMESTAMP index in watchdog.... I can't remember if it comes from default drupal instalation. If not, this sql is going to eat your resources reading the entire wathcdog each time.

<?php
$output
='';
$items = db_query('select location, message from watchdog where type="search" and timestamp > (UNIX_TIMESTAMP() - 7200)  order by timestamp desc');
while (
$item = db_fetch_object($items)) {
$output .= '<a href="'.$item->location.'">'.$item->message.'</a> ';
$output = str_replace('(<em>views_fastsearch</em>).', '', $output);
}
print
$output;
?>

regards, Gustavo
www.fechasdebandas.com.ar

 
 

Drupal is a registered trademark of Dries Buytaert.