drupal7 关于modules

本文介绍了Drupal的内容管理系统中模块和Hooks的工作原理。Drupal通过模块化的架构实现功能的扩展与禁用,而Hooks作为核心机制之一,允许开发者在特定时刻插入自定义行为。

drupal是modules组成的一个架构。功能被包含在modules里面,能运用也可以被禁用。

drupal反向控制设计模式,在适当的时间,modular功能被架构调用。同时modules开始工作,也被叫做hooks——勾住。

hooks可以被看作是drupal内部的事件。但是又有些不同与事件。

比如,一个用户登陆,drupal激活 hook_user_login,同时其他相关modules中的按照命名规则,以_user_login结尾的程序都要被调用。比如 comment module 里面的comment_user_login;node module里面的node_user_login;等等。

http://api.drupal.org/api/7 《官方文档》

在篇文档里面说的更加清楚,

Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.

To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and calls that hook in all enabled modules that implement it.

The available hooks to implement are explained here in the Hooks section of the developer documentation. The string "hook" is used as a placeholder for the module name in the hook definitions. For example, if the module file is called example.module, then hook_help() as implemented by that module would be defined as example_help().

The example functions included are not part of the Drupal core, they are just models that you can modify. Only the hooks implemented within modules are executed when running Drupal.

drupal的modules系统是基于“hooks”的理念。一个hook是一个php程序,被命名为 foo_bar(),foo就是module的名字,文件名就叫做foo.module.而bar是钩子的名字。每个钩子都有定义配套参数和特殊的返回结果类型。

向drupal延伸,一个module需要简单的执行一个钩子。当drupal希望允许介入modules,他要决定那个modules执行一个钩子,并在所有可用的modules里面调用和执行它。

“hook”这个字符串就像一个占位符。当有一个example.module,当执行hook_help(),对这个module来说就是被定义的example_help()程序。

 

 

转载于:https://www.cnblogs.com/rorodo/archive/2013/02/19/2916431.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值