Community & Support

Show Latest Searches of the entire site

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

All searchs are logged via

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: Acquia

Rosamunda, Use the

Rosamunda,
Use the zeitgeist module.

newms

Thanks!!

A piece of cake :-) loved it

Rosamunda
Buenos Aires | Argentina
www.ligadelconsorcista.org

Rosamunda
Buenos Aires | Argentina

Last Searchs in a block (search + fastsearch)

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

nobody click here