display recently accessed nodes

alihammad - June 16, 2008 - 07:06

Hi all,

I was wondering if there was a module which presented a block showing recently accessed nodes. I think it can be done by accessing the watchdog table. Is it possible? It would save me time if it has already been done before in some way or the other (be it a snippet or a module).

Ali Hammad Raza
WordsValley

Recent Blocks

ScoutBaker - June 16, 2008 - 07:13

Try Recent Blocks.

"Nice to meet you Rose...run for your life." - The Doctor

Doesn't work. Recent

alihammad - June 16, 2008 - 10:18

Doesn't work.

Recent blocks module show nodes according to one of the following options

* Modification or last post date
* Node creation date
* Node modification date (either create or last edit date)
* Last post date

None of the above displays list of recently accessed nodes. Thanks for the effort.

Ali Hammad Raza
WordsValley

If I understand correctly

ghumpley - June 16, 2008 - 12:38

If I understand correctly what you're after, wouldn't the Views module be what you're looking for? Just create a block view and under sort criteria select "Node: Last Hit Time"

Unfortunately there is no

alihammad - June 16, 2008 - 13:20

Unfortunately there is no such thing! I double checked to see if there was Node: Last Hit time but in fact there isn't. On careful analysis I found out that no data of such sort is stored in the first place. Drupal does not keep records of last node accesses in watchdog or any related table.

But, I have found the solution. I had to install the statistics module.
Statistics module keeps information of
# Top referrers
# Top pages
# Top visitors
# Recent hits

I used the accesslog table created by statistics module in this snippet.

<?php
global $user;
$result = db_query("SELECT DISTINCT title, path FROM {accesslog} WHERE uid != 1 ORDER BY timestamp DESC LIMIT 24");
while (
$row = db_fetch_object($result)) {
        if (
$row->title!="Page not found" AND $row->title!="Home" AND $row->title!="Log out" AND $row->title!="User account" AND $row->title!="RSS feed")
            {
             
$links[] =  l($row->title ? $row->title : t('Home'), $row->path);
            }
}
echo
"<br/>";
echo
"<h3>Nodes currently open:- </h3>";
echo
theme('item_list', $links);
?>

Ali Hammad Raza
WordsValley

There is such a thing cause

ghumpley - June 16, 2008 - 17:01

There is such a thing cause I use it on all my sites! But it won't be available unless you've got the logs enabled. Go to admin/logs/settings and make sure "Count content views:" is enabled. Then go back to your view and check the sort criteria, it should be there. I think that option is disabled by default when the statistics module is enabled so it's easy to miss. The statistics module is one that I always enable on any new installation, so I always just assume it's enabled for everyone, my fault!

 
 

Drupal is a registered trademark of Dries Buytaert.