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
Try Recent Blocks.
"Nice to meet you Rose...run for your life." - The Doctor
Doesn't work. Recent
Doesn't work.
Recent blocks module show nodes according to one of the following options
None of the above displays list of recently accessed nodes. Thanks for the effort.
Ali Hammad Raza
WordsValley
If I understand correctly
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
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.
<?phpglobal $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
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!