By audleman on
I am trying to find out if there exists a counter for the number of views of any node. I would like to display that information on my site (e.g. this page has been viewed 2,136 times). Does anybody know if this exists, either in the core code or in a module?
Thanks,
Kevin
Comments
I believe it's part of the
I believe it's part of the core statistics module.
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
It doesn't look like it...
WorldFallz,
Thanks for the reply. Your idea certainly sounded plausible, so I checked out the statistics module. It looks like it tracks things like page add/change/delete, but not page views.
Kevin
did you enable content views
did you enable content views at admin/reports/settings?
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
I don't see that menu...
I've searched all over the admin menus and can't find that page. I'm using version 5 -- is that something that's in a later version?
Kevin
log
try to look in administer->log-> (settings log visits ??)its translation from polish language version so for sure loook in all log menus
log
Sorry, still not seeing it. Seriously, I have scoured the menus, I have tried typing a direct URL into my browser window:
admin/logs/settings
...and I see nothing. It just doesn't seem like it exists. At this point I am researching how to create a new module to log page views.
I figure I will create a new module called node_hit_counter that will define a database table node_hit_counter with fields (nid, vid, hit_count).
Then I'll implement hook_nodeapi and look for 'view' type events for nodes of type 'story'. When one of those happens, I'll update the record in my table.
Seems like the most straightforward way of doing things.
Thanks to everyone who is trying to help...
Kevin
Eh?
Why write a module for what core already does? Enable the statistics module and go to example.com/admin/logs/settings and enable "Count content views" then go to access control and make sure you allow viewing them for whatever roles.
Michelle
--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.
yep-- Michelle is correct.
yep-- Michelle is correct. The path is admin/logs/settings (my bad, sorry for getting the URL wrong). You can also find it by clicking on "Administer" in the nav menu, then the "by module" tab, scroll down to the statistics module, and click on "access log settings". It's there in d5, just verified it.
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz
Found it!
Aaah, I had to enable the statistics module first. Thanks everyone!
Kevin
This is great, but does
This is great, but does anyone know how I can access that information through a view or service that is ?
As I am pulling in the information from services like 'views.getView' and 'node.load' ?
I'm not exactly sure what
I'm not exactly sure what you mean, but there are fields accessible to views for things like total hits, recent hits, most recent hit, etc.
===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime." -- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz