有没有一个钩子可以在我的模块中实现,这样我就可以在卸载我的模块时运行一些清理代码。我使用variable_set()创建了许多变量,并希望在卸载模块时删除这些变量。
发布于 2010-08-26 05:14:20
是的有。
你可以像下面这样写一个安装钩子:
/**
* Implements hook_install().
*/
function annotate_install(){
// Use schema API to create database table
drupal_install_schema('annotate');
}卸载过程如下所示:
/**
* Implements hook_uninstall().
*/
function annotate_uninstall(){
// Use scheme API to delete database table
drupal_uninstall_schema('annotate');
// Delete our module's variable from variables table
variable_del('annotate_node_types');
}https://stackoverflow.com/questions/3570202
复制相似问题