Bunun için özel bir modül yapmak zor olmamalı. istatistik modülü çalışır
sorgusu:
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());
}
Yapmamız gereken tek şey, bu özel bir Gönderen yapılabilir biz sayımını eklemek istediğiniz düğüm kimliği ile arg(1)
değiştirmektir buna benzer bir şey. Bütün bu geriye
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());
}
}
özel erişim kontrol işlevi uygulamak için, sen istek ajax olup olmadığını kontrol edebilir veya ne gibi kontrol yapabilir, fonksiyon sadece DOĞRU veya YANLIŞ dönmelidir. Ayrıca ayarınızda düğüm kimliği ile bir ajax olayı yapmanız gerekir, ancak bu da çok zor olmamalıdır.
Sen detaylı cevap için çok id 2 vs.
Teşekkür ile düğüm güncelleştirmek için url
custom/ajax/2
vurmak gerekir. Özel modülde çatlama olacak. – wiifmModülüm artık d.o http://drupal.org/project/statistics_ajax adresinden indirilebilir. – wiifm