Not sure if this is intended or not, but I'm noticing that node "view" activity is being recorded even when a node's teaser is shown. So, let's say you have a view on your home page that shows the 10 latest nodes... when a user visits the home page, it'll record that the user viewed all 10 of those nodes.
For my purposes, I'm interested in when a user views a node's page, not recording every time a node's teaser pops up somewhere. So, is this a bug? If not, any recommendations for how to just record node page views?
Thanks,
Chadwick
Comments
Comment #1
Scott Reynolds commentedYa saw this two when I started work on the D7 port. This is a bug.
Comment #2
sirkitree commentedWe could probably fix this in /modules/node.activity.inc with a hook_activity_records_alter() implementation. What do you think Scott?
Comment #3
sirkitree commentedHrm. Actually this doesn't happen for me right now. I've a couple stories on the home page (typical /node from fresh Drupal) and a publisher template setup for node view story. /activity/all doesn't show anything for these nodes until I click on one and show the first full view.
So I'd say that this is not really bug insofar as core functionality is concerned. It doesn't even seem to happen for views. If you enable the default 'frontpage' view which shows teasers in a typical manner, still nothing is recorded until you click into a story and view the full node.
Scott, do you think this is really a bug in 2.x?
Comment #4
jcisio commentedI don't know much about this module. However, there are a few examples for how to record node view activity: the core statistics module, or the menutrails module.
Comment #5
chadwick wood commentedYes, I'm using 2.x, and it's definitely happening for me, with views. My view lists node teasers.
I have a custom stats module I've written, part of which includes page views. I'm counting page views based off the activity module. My query to gather page views for a given node is:
So I'm just grabbing all the activity records for a given node, and counting them. I'm not filtering by op, but looking in my activity db table, every entry is for "view" op.
So, I reload my page with the view 4 times. Then, I visit my node, which lists it's own stats. The view count has been incremented by 5. I look at the database table, and I see all the new entries.
I would guess that this is because Activity is hooked into the 'view' op for nodeapi, and that that hook gets called when node_view() gets called, which Views is probably calling when it displays a teaser-based View. I don't know any of that for sure, but that would be my guess.
If I can give any more data on this that would help, just let me know. But I do feel pretty confident that a View that displays teasers will register an Activity "view" for every node shown.
Comment #6
jcisio commentedIt looks like that you are correct. The Views module (and Panels, or more exactly, Ctools page manager) makes it difficult. hook_nodeapi doesn't help here. Two things to do:
- Use what the core statistics.module uses: on hook_exit, check the path, if it is node/%nid, fire the 'view' activity.
- Use the mechanism provided by Ctools Page manager, example is at #362065: Panels Override Support. If you use Panels, the 'view' event may never fire.
I must confess that it's ugly. But it's the way contrib modules are designed. And sorry if you want to separate two issue (I'm not sure if Panels is an issue, it's untested, just a thought passing through, I had a very limited Activity test).
Comment #7
jcisio commentedHope someone can resolve this quickly so that we can have an official release. I don't know much about Activity (and I'm not ready to learn about it), so I'm sorry that I can't help more.
Comment #8
Scott Reynolds commentedhttp://drupal.org/cvs?commit=427788
And that will work fine with panels overrides.