I'm looking at the documentation for hook_exit, and the only parameter is $destination.
However the example code is:
function hook_exit($destination = NULL) {
db_query('UPDATE {counter} SET hits = hits + 1 WHERE type = 1');
}
I'm wondering how this query updates for the specific node? Or maybe it doesn't? But the statistics module definitely does.
I want to modify the statistic module, and I really want to get access to uid & nid for the current node. I can't find anywhere in the documentation what variables are available.
The statistics module hook_exit implementation is this:
function statistics_exit() {
global $user, $recent_activity;
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
if (variable_get('statistics_count_content_views', 0)) {
// We are counting content views.
if ((arg(0) == 'node') && is_numeric(arg(1)) && arg(2) == '') {
// A node has been viewed, so update the node's counters.
db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(1));
// If we affected 0 rows, this is the first time viewing the node.
if (!db_affected_rows()) {
// We must create a new row to store counters for the new node.