Where Hooks are Defined
nicesukhi1 - March 13, 2008 - 07:13
I have been looking through the Drupal code and have been trying to understand how it ticks. I understand the way that the hooks works, but do not understand where the base definitions are kept. I have been going through each of the files in my Drupal installation and do not see a definition of each of the hooks, except for init and exit. Where is this kept? How is it restricting which hooks are implementable?

http://api.drupal.org/api/gro
http://api.drupal.org/api/group/hooks/5
Thanks for your Help but still have some issues
I knew the link for the hook api but what i want is in drupal where these hooks are defined so that i can know what these are doing rather then checking it online.
I think you are looking for
I think you are looking for this.
<?php/**
* Determine whether a module implements a hook.
*
* @param $module
* The name of the module (without the .module extension).
* @param $hook
* The name of the hook (e.g. "help" or "menu").
* @return
* TRUE if the module is both installed and enabled, and the hook is
* implemented in that module.
*/
function module_hook($module, $hook) {
return function_exists($module .'_'. $hook);
}
?>
Check the common/module.inc for more details.
Different core hooks are
http://api.drupal.org/api/group/hooks/5
Hope this will help
Cheers.
Thanks for your Help but still have some issues
The things u told me are good but what i want is to see where these hook are declared in drupal that is what i want.
Did you mean this <?php/** *
Did you mean this
<?php
/**
* Implementation of hook_help().
*/
function modulename_help($section) {
// help content
}
/**
* Implementation of hook_menu().
*/
function modulename_menu($may_cache) {
// menu list
}
/**
* Implementation of hook_perm().
*/
function modulename_perm() {
return array('administer', users);
}
?>
These are declared in the modulename.module file of each modules.
For reference check user, comment and node (core) modules.
Hope this will help
Cheers.
http://api.drupal.org/api/gro
http://api.drupal.org/api/group/hooks/5 -> You see the list of different hooks and the column "Location" tells the file where that hook is declared.