安装和卸载模块时运行的 Drupal 钩子?
我正在尝试让 Drupal 运行自定义挂钩;一个需要在安装模块时运行,另一个需要在模块卸载时运行。是否有一个钩子或触发器可以让 Drupal 在安装或卸载模块时运行该钩子?我需要运行的钩子从数组构建分类术语。我的布局基于 hook_schema。该挂钩的实现示例如下:
function mymodule_install_taxonomy() {
return array(
<<Taxonomy Structure Here>>
);
}
该代码将放置在 .install 文件中。
I am trying to get a Drupal to run a custom hooks; one that needs to run when a module is being installed and another for when the module is being unistalled. Is there a hook or a trigger that I can use to have Drupal run the hook while the module is installing or uninstalling? The hook that I need to run builds taxonomy terms from an array. I am basing the lay out on the hook_schema. An example of the implementation of this hook is:
function mymodule_install_taxonomy() {
return array(
<<Taxonomy Structure Here>>
);
}
This code would be placed in the .install file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
什么时候安装你自己的模块还是其他人的模块?
对于您自己的,有 hook_install () (仅在第一次安装模块时调用,通常用于安装 Drupal 6 中 hook_schema() 中定义的模式,这在 Drupal 7 中是自动执行的),hook_uninstall(), hook_enable() (每次启用模块时调用)最后hook_disable()(当您的模块被禁用时)。
Drupal 7 还添加了一组类似的钩子,但在安装、卸载、启用或禁用其他模块时会调用这些钩子,请参阅hook_modules_*()
When your own module is installed or for others?
For your own, there is hook_install() (only called the first time your module is installed, usually used to install the schema defined in hook_schema() in Drupal 6, this is automated in Drupal 7), hook_uninstall(), hook_enable() (called every time your module is enabled) and finally hook_disable() (when your module is disabled).
Drupal 7 has also added a similar set of hooks that is however called when other modules are installed, uninstalled, enabled or disabled, see hook_modules_*()