function ajax_example_menu

Implements hook_menu().

Sets up calls to drupal_get_form() for all our example cases.

See also

menu_example.module

menu_example_menu()

Related topics

File

ajax_example/ajax_example.module, line 32

Code

function ajax_example_menu() {
    $items = array();
    $items['examples/ajax_example'] = array(
        'title' => 'AJAX Example',
        'page callback' => 'ajax_example_intro',
        'access callback' => TRUE,
        'expanded' => TRUE,
    );
    // Change the description of a form element.
    $items['examples/ajax_example/simplest'] = array(
        'title' => 'Simplest AJAX Example',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_simplest',
        ),
        'access callback' => TRUE,
        'weight' => 0,
    );
    // Generate a changing number of checkboxes.
    $items['examples/ajax_example/autocheckboxes'] = array(
        'title' => 'Generate checkboxes',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_autocheckboxes',
        ),
        'access callback' => TRUE,
        'weight' => 1,
    );
    // Generate different textfields based on form state.
    $items['examples/ajax_example/autotextfields'] = array(
        'title' => 'Generate textfields',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_autotextfields',
        ),
        'access callback' => TRUE,
        'weight' => 2,
    );
    // Submit a form without a page reload.
    $items['examples/ajax_example/submit_driven_ajax'] = array(
        'title' => 'Submit-driven AJAX',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_submit_driven_ajax',
        ),
        'access callback' => TRUE,
        'weight' => 3,
    );
    // Repopulate a dropdown based on form state.
    $items['examples/ajax_example/dependent_dropdown'] = array(
        'title' => 'Dependent dropdown',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_dependent_dropdown',
        ),
        'access callback' => TRUE,
        'weight' => 4,
    );
    // Repopulate a dropdown, but this time with graceful degredation.
    // See ajax_example_graceful_degradation.inc.
    $items['examples/ajax_example/dependent_dropdown_degrades'] = array(
        'title' => 'Dependent dropdown (with graceful degradation)',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_dependent_dropdown_degrades',
        ),
        'access callback' => TRUE,
        'weight' => 5,
        'file' => 'ajax_example_graceful_degradation.inc',
    );
    // The above example as it appears to users with no javascript.
    $items['examples/ajax_example/dependent_dropdown_degrades_no_js'] = array(
        'title' => 'Dependent dropdown with javascript off',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_dependent_dropdown_degrades',
            TRUE,
        ),
        'access callback' => TRUE,
        'file' => 'ajax_example_graceful_degradation.inc',
        'weight' => 5,
    );
    // Populate a form section based on input in another element.
    $items['examples/ajax_example/dynamic_sections'] = array(
        'title' => 'Dynamic Sections (with graceful degradation)',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_dynamic_sections',
        ),
        'access callback' => TRUE,
        'weight' => 6,
        'file' => 'ajax_example_graceful_degradation.inc',
    );
    // The  above example as it appears to users with no javascript.
    $items['examples/ajax_example/dynamic_sections_no_js'] = array(
        'title' => 'Dynamic Sections w/JS turned off',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_dynamic_sections',
            TRUE,
        ),
        'access callback' => TRUE,
        'weight' => 6,
        'file' => 'ajax_example_graceful_degradation.inc',
    );
    // A classic multi-step wizard, but with no page reloads.
    // See ajax_example_graceful_degradation.inc.
    $items['examples/ajax_example/wizard'] = array(
        'title' => 'Wizard (with graceful degradation)',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_wizard',
        ),
        'access callback' => TRUE,
        'file' => 'ajax_example_graceful_degradation.inc',
        'weight' => 7,
    );
    // The above example as it appears to users with no javascript.
    $items['examples/ajax_example/wizard_no_js'] = array(
        'title' => 'Wizard w/JS turned off',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_wizard',
            TRUE,
        ),
        'access callback' => TRUE,
        'file' => 'ajax_example_graceful_degradation.inc',
        'weight' => 7,
    );
    // Add-more button that creates additional form elements.
    // See ajax_example_graceful_degradation.inc.
    $items['examples/ajax_example/add_more'] = array(
        'title' => 'Add-more button (with graceful degradation)',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_add_more',
        ),
        'access callback' => TRUE,
        'file' => 'ajax_example_graceful_degradation.inc',
        'weight' => 8,
    );
    // The above example as it appears to users with no javascript.
    $items['examples/ajax_example/add_more_no_js'] = array(
        'title' => 'Add-more button w/JS turned off',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_add_more',
            TRUE,
        ),
        'access callback' => TRUE,
        'file' => 'ajax_example_graceful_degradation.inc',
        'weight' => 8,
    );
    // Use the AJAX framework outside the context of a form using the use-ajax
    // class. See ajax_example_misc.inc.
    $items['examples/ajax_example/ajax_link'] = array(
        'title' => 'Ajax Link ("use-ajax" class)',
        'page callback' => 'ajax_example_render_link',
        'access callback' => TRUE,
        'file' => 'ajax_example_misc.inc',
        'weight' => 9,
    );
    // Use the AJAX framework outside the context of a form using a renderable
    // array of type link with the #ajax property. See ajax_example_misc.inc.
    $items['examples/ajax_example/ajax_link_renderable'] = array(
        'title' => 'Ajax Link (Renderable Array)',
        'page callback' => 'ajax_example_render_link_ra',
        'access callback' => TRUE,
        'file' => 'ajax_example_misc.inc',
        'weight' => 9,
    );
    // A menu callback is required when using ajax outside of the Form API.
    $items['ajax_link_callback'] = array(
        'page callback' => 'ajax_link_response',
        'access callback' => 'user_access',
        'access arguments' => array(
            'access content',
        ),
        'type' => MENU_CALLBACK,
        'file' => 'ajax_example_misc.inc',
    );
    // Use AJAX framework commands outside of the #ajax form property.
    // See ajax_example_advanced.inc.
    $items['examples/ajax_example/advanced_commands'] = array(
        'title' => 'AJAX framework commands',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_advanced_commands',
        ),
        'access callback' => TRUE,
        'file' => 'ajax_example_advanced.inc',
        'weight' => 100,
    );
    // Autocomplete examples.
    $items['examples/ajax_example/simple_autocomplete'] = array(
        'title' => 'Autocomplete (simple)',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_simple_autocomplete',
        ),
        'access arguments' => array(
            'access user profiles',
        ),
        'file' => 'ajax_example_autocomplete.inc',
        'weight' => 10,
    );
    $items['examples/ajax_example/simple_user_autocomplete_callback'] = array(
        'page callback' => 'ajax_example_simple_user_autocomplete_callback',
        'file' => 'ajax_example_autocomplete.inc',
        'type' => MENU_CALLBACK,
        'access arguments' => array(
            'access user profiles',
        ),
    );
    $items['examples/ajax_example/node_autocomplete'] = array(
        'title' => 'Autocomplete (node with nid)',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_unique_autocomplete',
        ),
        'access arguments' => array(
            'access content',
        ),
        'file' => 'ajax_example_autocomplete.inc',
        'weight' => 11,
    );
    $items['examples/ajax_example/unique_node_autocomplete_callback'] = array(
        'page callback' => 'ajax_example_unique_node_autocomplete_callback',
        'file' => 'ajax_example_autocomplete.inc',
        'type' => MENU_CALLBACK,
        'access arguments' => array(
            'access content',
        ),
    );
    $items['examples/ajax_example/node_by_author'] = array(
        'title' => 'Autocomplete (node limited by author)',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_node_by_author_autocomplete',
        ),
        'access callback' => TRUE,
        'file' => 'ajax_example_autocomplete.inc',
        'weight' => 12,
    );
    $items['examples/ajax_example/node_by_author_autocomplete'] = array(
        'page callback' => 'ajax_example_node_by_author_node_autocomplete_callback',
        'file' => 'ajax_example_autocomplete.inc',
        'type' => MENU_CALLBACK,
        'access arguments' => array(
            'access content',
        ),
    );
    // This is the landing page for the progress bar example. It uses
    // drupal_get_form() in order to build the form.
    $items['examples/ajax_example/progressbar'] = array(
        'title' => 'Progress bar example',
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
            'ajax_example_progressbar_form',
        ),
        'access arguments' => array(
            'access content',
        ),
        'file' => 'ajax_example_progressbar.inc',
    );
    // This is the callback route for the AJAX-based progress bar.
    $items['examples/ajax_example/progressbar/progress/%'] = array(
        'title' => 'Progress bar progress',
        'page callback' => 'ajax_example_progressbar_progress',
        'page arguments' => array(
            4,
        ),
        'type' => MENU_CALLBACK,
        'access arguments' => array(
            'access content',
        ),
        'file' => 'ajax_example_progressbar.inc',
    );
    return $items;
}