function ahah_example_menu in Examples for Developers 6
Implement hook_menu().
Note that each item has both an entry point to prepare the form, and also a callback function that provides and AHAH menu callback.
File
- ahah_example/
ahah_example.module, line 44 - Demo of some varieties of AHAH in Drupal 6. A tutorial based on this module is at http://randyfay.com/ahah.
Code
function ahah_example_menu() {
$items = array();
$items['examples/ahah_example'] = array(
'title' => 'AHAH Examples',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'ahah_example_simplest',
),
'access callback' => TRUE,
'file' => 'ahah_example_simplest_ahah.inc',
);
// Simple AHAH with its callback.
$items['examples/ahah_example/simplest_ahah'] = array(
'title' => 'Simplest',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'ahah_example_simplest',
),
'access callback' => TRUE,
'type' => MENU_DEFAULT_LOCAL_TASK,
'file' => 'ahah_example_simplest_ahah.inc',
'weight' => 0,
);
$items['examples/ahah_example/simplest_ahah/callback'] = array(
'page callback' => 'ahah_example_simplest_callback',
'access callback' => TRUE,
'file' => 'ahah_example_simplest_ahah.inc',
'type' => MENU_CALLBACK,
);
// Automatically generate checkboxes.
$items['examples/ahah_example/autocheckboxes'] = array(
'title' => 'Generate checkboxes',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'ahah_example_autocheckboxes',
),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'file' => 'ahah_example_autocheckboxes.inc',
);
$items['examples/ahah_example/autocheckboxes/callback'] = array(
'page callback' => 'ahah_example_autocheckboxes_callback',
'access callback' => TRUE,
'file' => 'ahah_example_autocheckboxes.inc',
'type' => MENU_CALLBACK,
);
// Automatically generate textfields.
$items['examples/ahah_example/autotextfields'] = array(
'title' => 'Generate textfields',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'ahah_example_autotextfields',
),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
'weight' => 4,
'file' => 'ahah_example_autotextfields.inc',
);
$items['examples/ahah_example/autotextfields/callback'] = array(
'page callback' => 'ahah_example_autotextfields_callback',
'access callback' => TRUE,
'file' => 'ahah_example_autotextfields.inc',
'type' => MENU_CALLBACK,
);
// Automatically generate textfields.
$items['examples/ahah_example/dependent_dropdown'] = array(
'title' => 'Degrading dependent dropdown',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'ahah_example_dropdown',
),
'access callback' => TRUE,
'weight' => 4,
'type' => MENU_LOCAL_TASK,
'file' => 'ahah_example_dependent_dropdown.inc',
);
$items['examples/ahah_example/dependent_dropdown/callback'] = array(
'page callback' => 'ahah_example_dropdown_callback',
'access callback' => TRUE,
'file' => 'ahah_example_dependent_dropdown.inc',
'type' => MENU_CALLBACK,
);
$items['examples/ahah_example/simple_validation'] = array(
'title' => 'Simple Validation',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'ahah_example_simple_validation',
),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
'file' => 'ahah_example_simple_validation.inc',
'weight' => 6,
);
$items['examples/ahah_example/simple_validation/callback'] = array(
'page callback' => 'ahah_example_simple_validation_callback',
'access callback' => TRUE,
'file' => 'ahah_example_simple_validation.inc',
'type' => MENU_CALLBACK,
);
return $items;
}