Created
January 25, 2017 11:04
-
-
Save martsie/daae1e971809656fe6b136753d112e65 to your computer and use it in GitHub Desktop.
hook_menu implementation for AJAX commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_menu(). | |
*/ | |
function MY_CUSTOM_MODULE_menu() { | |
// Returns AJAX commands if the user has JavaScript turned on. | |
$items['my-custom-path/ajax'] = array( | |
'title' => 'My custom ajax callback', | |
'page callback' => 'MY_CUSTOM_MODULE_ajax_callback', | |
'access arguments' => array('access content'), | |
'type' => MENU_CALLBACK, | |
); | |
// Returns a Non-JavaScript alternative. | |
$items['my-custom-path/nojs'] = array( | |
'title' => 'My custom non-javascript callback', | |
'page callback' => 'MY_CUSTOM_MODULE_nojs_callback', | |
'access arguments' => array('access content'), | |
'type' => MENU_CALLBACK, | |
); | |
// The page that will run the command. | |
$items['my-custom-path/trigger-page'] = array( | |
'title' => 'AJAX trigger page', | |
'page callback' => 'MY_CUSTOM_MODULE_trigger_page', | |
'access arguments' => array('access content'), | |
'type' => MENU_CALLBACK, | |
); | |
return $items; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment