The documentation has very little information about the "view type" property defined when I'm beginning to create a view. I'm referring to the "view type" on admin/build/views/add ("Node", "User", etc), not the other "view type". The help should include more information about these options, possibly including a list of fields available for each.
I'm trying to create a view of my nodes with their pageviews, which I think would imply either a "Node" view type or an "Access Log" view type, but under the "fields" I can't get any kind of counter of the node's views. Under "Access Log", I can get a list of the usernames and timestamps of everyone who visited the node, but not a simple count of them. Ultimately, I'd like two columns, one of total views and one of unique views, but I don't see any way how to do this.
Comments
Comment #1
dawehnerIf you have enable the statistics module you can have the following view:
Comment #2
a.bond commentedThanks for that! I didn't see the "Node statistics: Total Views" field before. Is that each hit, or only unique hits? Also, is there a way to restrict the view count to only views in a specified date range?
Comment #3
dawehnerI don't know whether its each hit or unique, i guess first. But this is drupal core, so views cannot do anything.
There are also a view todays visits field.
If you need custom range, you could write your own field handler.
Comment #4
a.bond commentedHow does one write their own field handler? Is there any documentation on this?
Comment #5
dawehnerYes there is documentation in the advanced help of views or the same page on http://views-help.doc.logrus.com/help/views/api
If you want to jump in deeper into views read http://views.doc.logrus.com/ :)
Comment #6
a.bond commentedThe advanced help and the api are useful, but very hard to read. It looks like I'd need to create a new module that's dependent on Views, and my new handler should be in a views_handler_field_handlername.inc ? Or since it's a new module, should it be modulename_handler_etc? Is there something that I need to put in the .module file to call the .inc file? If I want to make a handler that derives a node's view count from the accesslog in a way that it can be filtered by date or date range, is there an accesslog handler it can extend, or do I have to build it entirely as an extension of views_handler_field ?
Sorry for all the questions, but it's hard for me to find my way through all this.
Comment #7
dawehnerYes you need to create a module exact.
There is something like a naming convention modulename_handler_type_handlername, where type is filter/field/sort.
To be able to use it you need hook_views_api and hook_views_handler and hook_views_data_alter
There is currently afaik no data for accesslogs
Anyway read http://views-help.doc.logrus.com/help/views/api-tables and http://views-help.doc.logrus.com/help/views/api-handlers
There is quite a lot documented.
Comment #8
mactoph commentedIssue appears to be solved.