Implementation of hooks in Drupal

In your directory /sites/all/, you have to create 2 sub-directories called “themes” and “modules” where your custom themes and modules are located.

What “hooks” in Drupal is all about? They allow your custom-built modules to interact with the Drupal core.  A hook is a function that is named foo_hookname(), where “foo” is the name of your custom-built module (whose filename is foo.module) and “hookname” is the name of the hook. Each hook has a defined set of parameters and a specified result type.

To extend Drupal system, your custom-built module needs to 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.

In Drupal 6.x there’re more than 70 hooks that you got to remember in case your internet is down. My next posts will show you how to implement each of these hooks in your custom modules.

hook_access
hook_actions_delete
hook_action_info
hook_action_info_alter
hook_block
hook_boot
hook_comment
hook_cron
hook_db_rewrite_sql
hook_delete
hook_disable
hook_elements
hook_enable
hook_exit
hook_file_download
hook_filter
hook_filter_tips
hook_flush_caches
hook_footer
hook_form
hook_forms
hook_form_alter
hook_form_FORM_ID_alter
hook_help
hook_hook_info
hook_inithook_insert
hook_install
hook_link
hook_link_alter
hook_load
hook_locale
hook_mail
hook_mail_alter
hook_menu
hook_menu_alter
hook_menu_link_alter
hook_nodeapi
hook_node_access_records
hook_node_grants
hook_node_info
hook_node_operations
hook_node_type
hook_perm
hook_ping
hook_prepare
hook_profile_alter
hook_requirements
hook_schema

hook_schema_alter
hook_search
hook_search_preprocess
hook_system_info_alter
hook_taxonomy
hook_term_path
hook_theme
hook_theme_registry_alter
hook_translated_menu_link_alter
hook_translation_link_alter
hook_uninstall
hook_update
hook_update_index
hook_update_last_removed
hook_update_N
hook_update_projects_alter
hook_update_status_alter
hook_user
hook_user_operations
hook_validate
hook_view
hook_watchdog
hook_xmlrpc
module_hook
module_implements
module_invoke
module_invoke_all