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

Comments

pwolanin’s picture

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.

---
Work: BioRAFT

newms’s picture

Rosamunda,
Use the zeitgeist module.

newms

Rosamunda’s picture

A piece of cake :-) loved it

Rosamunda
Buenos Aires | Argentina
www.ligadelconsorcista.org

adminfor@inforo.com.ar’s picture

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