Closed (fixed)
Project:
MongoDB
Version:
7.x-1.x-dev
Component:
Field storage
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Feb 2013 at 19:00 UTC
Updated:
23 Feb 2013 at 03:32 UTC
Adding total views count as a field or filter works fine but it's not available as a sort for some reason like it is on regular content views.
Comments
Comment #1
mcrittenden commentedUpdates, doesn't work as a filter either, and it appears that view counts are not stored by mongo at all. So it sounds like mongo first needs to make node view counts available before this can be accomplished. Moving this to postponed until #1125886: Support of the core statistics module or something like it lands.
Comment #2
mcrittenden commentedI ended up just hacking my way around this by 1) adding a regular integer field for view count to the content type, 2) incrementing that field via a custom script that avoids a full drupal bootstrap, and 3) adding the new field to the view as a sort.
Script is below. Put it in the site root as inc.php and use it as an image src like
<img src="/inc.php?nid=<nid>" />whenever you want to increment something. It outputs a 1x1 gif. Thanks to @chx for the bulk of this code.Comment #3
mcrittenden commentedComment #4
chx commentedAlso please share the Views code. I guess it's a hook_views_data_alter() against efq.
Comment #5
mcrittenden commentedNo views code. It's just a regular field added to the content type via the fields GUI, so views can display it and sort by it without any custom code. Like I said, it's a hack, but it worked fine in this situation.
Comment #6
chx commentedOh I missed that! Very tricky. Will commit something to this end.