Hi All,
When creating a single Page display in Views (4.7.x), Views doesn't seem to update the daycount
or totalcount in node_counter. Technically, the url is the Views url, so whatever does the core counter update doesn't have the proper Node ID of the page that was displayed by the View to update the proper Node counters.
Tried (didn't work):
<?php
global $current_view;
print $GLOBALS['current_view']->url;
print $GLOBALS['current_view']->num_rows;
$nodeid=$node->nid;
print $nodeid;
print($node->nid);
print($arg[0]);
?>
Prints:
RandomFrontPage.html
1
NULL
NULL
NULL
Basically it should be simple to find the displayed Node ID, and then run this:
db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(1));
to update the counters. But I'm running into a blank wall trying to guess whatever the proper terminology is.
So, does anyone know some code to place in the Views' (footer?) so that the displayed Node's ID is determined and the proper update can be made to node_counter? Preferably with proper syntax?
Thanks,
M.J. Taylor
Publisher
from Reason to Freedom
Comments
After re-reading the post,
After re-reading the post, Statistics: exclude admin from content view count, would it just be possible to set the global arg(1) to the displayed content's Node ID? Then just let the regular statistics_exit() do the work?
MJ
Solution and Handbook
Solution and Handbook writeup:
HowTo: Create a Random, Single, Full Node on Your Home Page (4.7.x/5.x)
M.J. Taylor
Publisher
from Reason to Freedom
Wekly libertarian magazine promoting thinking for oneself, thus helping to create a free, benevolent society.
Okay, In a blind attempt,
Okay,
In a blind attempt, since the API section of Views is almost empty, does anyone know how to extract the nid from:
Prints:
nid
NULL
The full listing of the array is below, if someone could just point me at the right variable/syntax, I can do the rest.
Thanks,
M.J. Taylor
Publisher
from Reason to Freedom
Wekly libertarian magazine promoting thinking for oneself, thus helping to create a free, benevolent society.