谢谢你的回答,最后我用jQuery做到了。
我做到了:
在 mymodule.js 文件中:
jQuery(document).ready(function() {
if (window.location.href == "http://loc") {
setInterval(check, 5000);
}
function check() {
$ret = 0;
jQuery.get("/path/to/check_slide", function( data ) {
if(data == 1) {
location.reload();
}
})
}
})
在drupal模块中我做了:
在 hook_init 中:
drupal_add_js(drupal_get_path('module', 'mymodule') . 'mymodule.js');
在钩子菜单中:
$items['/path/to/check_slide'] = array(
'page callback' => 'mymodule_check_slide',
'access callback' => TRUE,
'type' => MENU_CALLBACK, );
在 mymodule_check_slide 中:
$ret = 0;
if (variable_get('flag', 0)) {
$ret = 1;
variable_set('flag', 0);
}
print $ret;
die();
}
在 hook_node_presave 中:
if ($node -> type == 'slidetype') {
variable_set('flag', 1);
}