このためのカスタム モジュールを作成するのは難しくありません。
統計モジュールが実行するクエリは次のとおりです。
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.
db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES (%d, 1, 1, %d)', arg(1), time());
}
必要な唯一のことは、arg(1)これにカウントを追加したいノード ID に置き換えることです。これは、このようなカスタム モジュールで実行できます。
function custom_module_menu() {
$items['custom/ajax/%node'] = array(
'title' => 'Update count',
'page callback' => 'custom_module_update_counter',
'page arguments' => array(2),
'access callback' => array('custom_module_access_control'),
);
function custom_module_update_counter($node) {
db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), $node->nid);
// 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.
db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES (%d, 1, 1, %d)', $node->nid, time());
}
}
あとは、カスタム アクセス制御関数を実装するだけです。リクエストが ajax かどうかを確認したり、好きなように制御したりできます。関数は TRUE または FALSE を返すだけです。また、設定でノード ID を使用して ajax イベントを作成する必要がありますが、それも難しくありません。
custom/ajax/2ID 2 などでノードを更新するには、URL にアクセスする必要があります。