模块卸载清理

San*_*eon 2 drupal drupal-6 drupal-modules

我可以在我的模块中实现一个钩子,以便在卸载模块时可以运行一些清理代码.我使用创建了许多变量variable_set(),我想在卸载模块时删除这些变量.

rlb*_*usa 5

就在这里.

你会在哪里写一个这样的安装钩子:

/**
 * Implements hook_install().
 */   
function annotate_install(){
    // Use schema API to create database table
    drupal_install_schema('annotate');
}
Run Code Online (Sandbox Code Playgroud)

卸载看起来像这样:

/**
 * 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');
}
Run Code Online (Sandbox Code Playgroud)