Skip to main content

What makes drupal powerful? Its the hook system which makes it powerful because all the modules will use hooks to interact with the rest of the drupal system.

By creating our own hook, we are making our module much more powerful and useful beacuse other modules will extend out hook or change the data in some way.

The best way to understand is through an example.

Created a module called custom_drupal7 and defined hook_menu and a callback function for it.

 * Implements hook_menu
function custom_drupal7_menu() {  
  $items = array();  
  $items['custom_profiles'] = array(
      'title' => 'List Of Profiles',
      'page callback' => 'custom_drupal7_callback',
      'access arguments' => array('access content'),
      'type' => MENU_CALLBACK,
  return $items;
 * List of people included in a round of profile.
function custom_drupal7_callback() {
  $round = array('pown','john','Ram','Raj','Kannan','Charlie','Senthil');
  $round_more = module_invoke_all('custom_drupal7');
  $round_all = array_merge($round, $round_more);
  $output = theme('item_list', array('items' => $round_all)); 
  return $output;

Created a new module called custom_me and used the hook_custom_drupal7


function custom_me_custom_drupal7(){
  return 'Veera';

That is all there is to invoking a hook! This is a very simple example to get you started.